1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.easymock.tests; |
18 |
|
|
19 |
|
import static org.easymock.EasyMock.*; |
20 |
|
import static org.junit.Assert.*; |
21 |
|
|
22 |
|
import org.easymock.internal.RecordState; |
23 |
|
import org.junit.Before; |
24 |
|
import org.junit.Test; |
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 85,7% |
Uncovered Elements: 3 (21) |
Complexity: 7 |
Complexity Density: 0,41 |
|
29 |
|
public class RecordStateInvalidStateChangeTest { |
30 |
|
|
31 |
|
private IMethods mock; |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
33 |
6
|
@Before... |
34 |
|
public void setup() { |
35 |
6
|
mock = createMock(IMethods.class); |
36 |
|
} |
37 |
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,33 |
1
PASS
|
|
38 |
2
|
@Test... |
39 |
|
public void activateWithoutReturnValue() { |
40 |
2
|
expect(mock.oneArg(false)); |
41 |
2
|
try { |
42 |
2
|
replay(mock); |
43 |
0
|
fail("IllegalStateException expected"); |
44 |
|
} catch (final IllegalStateException e) { |
45 |
2
|
assertEquals("missing behavior definition for the preceding method call oneArg(false)", e |
46 |
|
.getMessage()); |
47 |
2
|
assertTrue("stack trace must be cut", |
48 |
|
Util.getStackTrace(e).indexOf(RecordState.class.getName()) == -1); |
49 |
|
} |
50 |
|
} |
51 |
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,33 |
1
PASS
|
|
52 |
2
|
@Test... |
53 |
|
public void secondCallWithoutReturnValue() { |
54 |
2
|
mock.oneArg(false); |
55 |
2
|
try { |
56 |
2
|
mock.oneArg(false); |
57 |
0
|
fail("IllegalStateException expected"); |
58 |
|
} catch (final IllegalStateException e) { |
59 |
2
|
assertEquals("missing behavior definition for the preceding method call oneArg(false)", e |
60 |
|
.getMessage()); |
61 |
2
|
assertTrue("stack trace must be cut", |
62 |
|
Util.getStackTrace(e).indexOf(RecordState.class.getName()) == -1); |
63 |
|
} |
64 |
|
} |
65 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
66 |
2
|
@Test... |
67 |
|
public void verifyWithoutActivation() { |
68 |
2
|
try { |
69 |
2
|
verify(mock); |
70 |
0
|
fail("IllegalStateException expected"); |
71 |
|
} catch (final IllegalStateException e) { |
72 |
2
|
assertEquals("calling verify is not allowed in record state", e.getMessage()); |
73 |
|
} |
74 |
|
} |
75 |
|
} |