| 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") |
|
|
|
| 84,2% |
Uncovered Elements: 6 (38) |
Complexity: 13 |
Complexity Density: 0,42 |
|
| 14 |
|
public class RecordStateInvalidDefaultReturnValueTest { |
| 15 |
|
MockControl<IMethods> control; |
| 16 |
|
|
| 17 |
|
IMethods mock; |
| 18 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 19 |
6
|
@Before... |
| 20 |
|
public void setup() { |
| 21 |
6
|
control = MockControl.createControl(IMethods.class); |
| 22 |
6
|
mock = control.getMock(); |
| 23 |
|
} |
| 24 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 25 |
1
|
@Test... |
| 26 |
|
public void setInvalidDefaultBooleanReturnValue() { |
| 27 |
1
|
mock.oneArg(false); |
| 28 |
1
|
try { |
| 29 |
1
|
control.setDefaultReturnValue(false); |
| 30 |
0
|
fail("IllegalStateException expected"); |
| 31 |
|
} catch (IllegalStateException e) { |
| 32 |
1
|
assertEquals("incompatible return value type", e.getMessage()); |
| 33 |
|
} |
| 34 |
|
} |
| 35 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 36 |
1
|
@Test... |
| 37 |
|
public void setInvalidDefaultLongReturnValue() { |
| 38 |
1
|
mock.oneArg(false); |
| 39 |
1
|
try { |
| 40 |
1
|
control.setDefaultReturnValue((long) 0); |
| 41 |
0
|
fail("IllegalStateException expected"); |
| 42 |
|
} catch (IllegalStateException e) { |
| 43 |
1
|
assertEquals("incompatible return value type", e.getMessage()); |
| 44 |
|
} |
| 45 |
|
} |
| 46 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 47 |
1
|
@Test... |
| 48 |
|
public void setInvalidDefaultFloatReturnValue() { |
| 49 |
1
|
mock.oneArg(false); |
| 50 |
1
|
try { |
| 51 |
1
|
control.setDefaultReturnValue((float) 0); |
| 52 |
0
|
fail("IllegalStateException expected"); |
| 53 |
|
} catch (IllegalStateException e) { |
| 54 |
1
|
assertEquals("incompatible return value type", e.getMessage()); |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 58 |
1
|
@Test... |
| 59 |
|
public void setInvalidDefaultDoubleReturnValue() { |
| 60 |
1
|
mock.oneArg(false); |
| 61 |
1
|
try { |
| 62 |
1
|
control.setDefaultReturnValue((double) 0); |
| 63 |
0
|
fail("IllegalStateException expected"); |
| 64 |
|
} catch (IllegalStateException e) { |
| 65 |
1
|
assertEquals("incompatible return value type", e.getMessage()); |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 69 |
1
|
@Test... |
| 70 |
|
public void setInvalidObjectDefaultReturnValue() { |
| 71 |
1
|
mock.oneArg(false); |
| 72 |
1
|
try { |
| 73 |
1
|
control.setDefaultReturnValue(new Object()); |
| 74 |
0
|
fail("IllegalStateException expected"); |
| 75 |
|
} catch (IllegalStateException e) { |
| 76 |
1
|
assertEquals("incompatible return value type", e.getMessage()); |
| 77 |
|
} |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 80 |
1
|
@Test... |
| 81 |
|
public void setDefaultReturnValueWithoutMethodCall() { |
| 82 |
1
|
try { |
| 83 |
1
|
control.setDefaultReturnValue(new Object()); |
| 84 |
0
|
fail("IllegalStateException expected"); |
| 85 |
|
} catch (IllegalStateException e) { |
| 86 |
1
|
assertEquals( |
| 87 |
|
"method call on the mock needed before setting default return value", |
| 88 |
|
e.getMessage()); |
| 89 |
|
} |
| 90 |
|
} |
| 91 |
|
} |