| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
package org.easymock.tests; |
| 6 |
|
|
| 7 |
|
import static org.junit.Assert.*; |
| 8 |
|
|
| 9 |
|
import org.easymock.MockControl; |
| 10 |
|
import org.junit.Before; |
| 11 |
|
import org.junit.Test; |
| 12 |
|
|
| 13 |
|
@SuppressWarnings("deprecation") |
|
|
|
| 83,3% |
Uncovered Elements: 11 (66) |
Complexity: 23 |
Complexity Density: 0,43 |
|
| 14 |
|
public class RecordStateInvalidUsageTest { |
| 15 |
|
|
| 16 |
|
MockControl<IMethods> control; |
| 17 |
|
|
| 18 |
|
IMethods mock; |
| 19 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 20 |
11
|
@Before... |
| 21 |
|
public void setup() { |
| 22 |
11
|
control = MockControl.createControl(IMethods.class); |
| 23 |
11
|
mock = control.getMock(); |
| 24 |
|
} |
| 25 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 26 |
1
|
@Test... |
| 27 |
|
public void setReturnValueWithoutMethodCall() { |
| 28 |
1
|
try { |
| 29 |
1
|
control.setReturnValue(false); |
| 30 |
0
|
fail("IllegalStateException expected"); |
| 31 |
|
} catch (IllegalStateException expected) { |
| 32 |
1
|
assertEquals( |
| 33 |
|
"method call on the mock needed before setting return value", |
| 34 |
|
expected.getMessage()); |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 38 |
1
|
@Test... |
| 39 |
|
public void setExpectedVoidCallCountWithoutMethodCall() { |
| 40 |
1
|
try { |
| 41 |
1
|
control.setVoidCallable(3); |
| 42 |
0
|
fail("IllegalStateException expected"); |
| 43 |
|
} catch (IllegalStateException expected) { |
| 44 |
1
|
assertEquals( |
| 45 |
|
"method call on the mock needed before setting void callable", |
| 46 |
|
expected.getMessage()); |
| 47 |
|
} |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 50 |
1
|
@Test... |
| 51 |
|
public void openVoidCallCountWithoutMethodCall() { |
| 52 |
1
|
try { |
| 53 |
1
|
control.setVoidCallable(); |
| 54 |
0
|
fail("IllegalStateException expected"); |
| 55 |
|
} catch (Exception expected) { |
| 56 |
1
|
assertEquals( |
| 57 |
|
"method call on the mock needed before setting void callable", |
| 58 |
|
expected.getMessage()); |
| 59 |
|
} |
| 60 |
|
} |
| 61 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 62 |
1
|
@Test... |
| 63 |
|
public void setWrongReturnValueBoolean() { |
| 64 |
1
|
mock.oneArg(false); |
| 65 |
1
|
try { |
| 66 |
1
|
control.setReturnValue(false); |
| 67 |
0
|
fail("IllegalStateException expected"); |
| 68 |
|
} catch (IllegalStateException expected) { |
| 69 |
1
|
assertEquals("incompatible return value type", expected |
| 70 |
|
.getMessage()); |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 74 |
1
|
@Test... |
| 75 |
|
public void setWrongReturnValueShort() { |
| 76 |
1
|
mock.oneArg(false); |
| 77 |
1
|
try { |
| 78 |
1
|
control.setReturnValue((short) 0); |
| 79 |
0
|
fail("IllegalStateException expected"); |
| 80 |
|
} catch (IllegalStateException expected) { |
| 81 |
1
|
assertEquals("incompatible return value type", expected |
| 82 |
|
.getMessage()); |
| 83 |
|
} |
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 86 |
1
|
@Test... |
| 87 |
|
public void setWrongReturnValueChar() { |
| 88 |
1
|
mock.oneArg(false); |
| 89 |
1
|
try { |
| 90 |
1
|
control.setReturnValue((char) 0); |
| 91 |
0
|
fail("IllegalStateException expected"); |
| 92 |
|
} catch (IllegalStateException expected) { |
| 93 |
1
|
assertEquals("incompatible return value type", expected |
| 94 |
|
.getMessage()); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 98 |
1
|
@Test... |
| 99 |
|
public void setWrongReturnValueInt() { |
| 100 |
1
|
mock.oneArg(false); |
| 101 |
1
|
try { |
| 102 |
1
|
control.setReturnValue(0); |
| 103 |
0
|
fail("IllegalStateException expected"); |
| 104 |
|
} catch (IllegalStateException expected) { |
| 105 |
1
|
assertEquals("incompatible return value type", expected |
| 106 |
|
.getMessage()); |
| 107 |
|
} |
| 108 |
|
} |
| 109 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 110 |
1
|
@Test... |
| 111 |
|
public void setWrongReturnValueLong() { |
| 112 |
1
|
mock.oneArg(false); |
| 113 |
1
|
try { |
| 114 |
1
|
control.setReturnValue((long) 0); |
| 115 |
0
|
fail("IllegalStateException expected"); |
| 116 |
|
} catch (IllegalStateException expected) { |
| 117 |
1
|
assertEquals("incompatible return value type", expected |
| 118 |
|
.getMessage()); |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 122 |
1
|
@Test... |
| 123 |
|
public void setWrongReturnValueFloat() { |
| 124 |
1
|
mock.oneArg(false); |
| 125 |
1
|
try { |
| 126 |
1
|
control.setReturnValue((float) 0); |
| 127 |
0
|
fail("IllegalStateException expected"); |
| 128 |
|
} catch (IllegalStateException expected) { |
| 129 |
1
|
assertEquals("incompatible return value type", expected |
| 130 |
|
.getMessage()); |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 134 |
1
|
@Test... |
| 135 |
|
public void setWrongReturnValueDouble() { |
| 136 |
1
|
mock.oneArg(false); |
| 137 |
1
|
try { |
| 138 |
1
|
control.setReturnValue((double) 0); |
| 139 |
0
|
fail("IllegalStateException expected"); |
| 140 |
|
} catch (IllegalStateException expected) { |
| 141 |
1
|
assertEquals("incompatible return value type", expected |
| 142 |
|
.getMessage()); |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 146 |
1
|
@Test... |
| 147 |
|
public void setWrongReturnValueObject() { |
| 148 |
1
|
mock.oneArg(false); |
| 149 |
1
|
try { |
| 150 |
1
|
control.setReturnValue(new Object()); |
| 151 |
0
|
fail("IllegalStateException expected"); |
| 152 |
|
} catch (IllegalStateException expected) { |
| 153 |
1
|
assertEquals("incompatible return value type", expected |
| 154 |
|
.getMessage()); |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
} |