| 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.easymock.internal.RecordState; |
| 11 |
|
import org.junit.Before; |
| 12 |
|
import org.junit.Test; |
| 13 |
|
|
| 14 |
|
@SuppressWarnings("deprecation") |
|
|
|
| 86,4% |
Uncovered Elements: 3 (22) |
Complexity: 7 |
Complexity Density: 0,39 |
|
| 15 |
|
public class RecordStateInvalidStateChangeTest { |
| 16 |
|
MockControl<IMethods> control; |
| 17 |
|
|
| 18 |
|
IMethods mock; |
| 19 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 20 |
3
|
@Before... |
| 21 |
|
public void setup() { |
| 22 |
3
|
control = MockControl.createControl(IMethods.class); |
| 23 |
3
|
mock = control.getMock(); |
| 24 |
|
} |
| 25 |
|
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,33 |
1
PASS
|
|
| 26 |
1
|
@Test... |
| 27 |
|
public void activateWithoutReturnValue() { |
| 28 |
1
|
mock.oneArg(false); |
| 29 |
1
|
try { |
| 30 |
1
|
control.replay(); |
| 31 |
0
|
fail("IllegalStateException expected"); |
| 32 |
|
} catch (IllegalStateException e) { |
| 33 |
1
|
assertEquals( |
| 34 |
|
"missing behavior definition for the preceeding method call oneArg(false)", |
| 35 |
|
e.getMessage()); |
| 36 |
1
|
assertTrue("stack trace must be cut", Util.getStackTrace(e) |
| 37 |
|
.indexOf(RecordState.class.getName()) == -1); |
| 38 |
|
} |
| 39 |
|
} |
| 40 |
|
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,33 |
1
PASS
|
|
| 41 |
1
|
@Test... |
| 42 |
|
public void secondCallWithoutReturnValue() { |
| 43 |
1
|
mock.oneArg(false); |
| 44 |
1
|
try { |
| 45 |
1
|
mock.oneArg(false); |
| 46 |
0
|
fail("IllegalStateException expected"); |
| 47 |
|
} catch (IllegalStateException e) { |
| 48 |
1
|
assertEquals( |
| 49 |
|
"missing behavior definition for the preceeding method call oneArg(false)", |
| 50 |
|
e.getMessage()); |
| 51 |
1
|
assertTrue("stack trace must be cut", Util.getStackTrace(e) |
| 52 |
|
.indexOf(RecordState.class.getName()) == -1); |
| 53 |
|
} |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 56 |
1
|
@Test... |
| 57 |
|
public void verifyWithoutActivation() { |
| 58 |
1
|
try { |
| 59 |
1
|
control.verify(); |
| 60 |
0
|
fail("IllegalStateException expected"); |
| 61 |
|
} catch (IllegalStateException e) { |
| 62 |
1
|
assertEquals("calling verify is not allowed in record state", e |
| 63 |
|
.getMessage()); |
| 64 |
|
} |
| 65 |
|
} |
| 66 |
|
} |