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.junit.Before; |
23 |
|
import org.junit.Test; |
24 |
|
|
25 |
|
|
26 |
|
@author |
27 |
|
|
|
|
| 85,3% |
Uncovered Elements: 5 (34) |
Complexity: 11 |
Complexity Density: 0,39 |
|
28 |
|
public class RecordStateInvalidRangeTest { |
29 |
|
|
30 |
|
private IMethods mock; |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
32 |
10
|
@Before... |
33 |
|
public void setup() { |
34 |
10
|
mock = createMock(IMethods.class); |
35 |
|
} |
36 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
37 |
2
|
@Test... |
38 |
|
public void setOpenCallCountTwice() { |
39 |
2
|
mock.simpleMethod(); |
40 |
2
|
try { |
41 |
2
|
expectLastCall().atLeastOnce().atLeastOnce(); |
42 |
0
|
fail(); |
43 |
|
} catch (final IllegalStateException expected) { |
44 |
2
|
assertEquals("last method called on mock already has a non-fixed count set.", expected |
45 |
|
.getMessage()); |
46 |
|
} |
47 |
|
} |
48 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
49 |
2
|
@Test... |
50 |
|
public void setCloseCallAfterOpenOne() { |
51 |
2
|
mock.simpleMethod(); |
52 |
2
|
try { |
53 |
2
|
expectLastCall().atLeastOnce().once(); |
54 |
0
|
fail(); |
55 |
|
} catch (final IllegalStateException expected) { |
56 |
2
|
assertEquals("last method called on mock already has a non-fixed count set.", expected |
57 |
|
.getMessage()); |
58 |
|
} |
59 |
|
} |
60 |
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,33 |
1
PASS
|
|
61 |
2
|
@Test... |
62 |
|
public void setIllegalMinimumCount() { |
63 |
2
|
mock.simpleMethod(); |
64 |
2
|
final int NEGATIVE = -1; |
65 |
2
|
try { |
66 |
2
|
expectLastCall().times(NEGATIVE, 2); |
67 |
0
|
fail(); |
68 |
|
} catch (final IllegalArgumentException expected) { |
69 |
2
|
assertEquals("minimum must be >= 0", expected.getMessage()); |
70 |
|
} |
71 |
|
} |
72 |
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,33 |
1
PASS
|
|
73 |
2
|
@Test... |
74 |
|
public void setIllegalMaximumCount() { |
75 |
2
|
mock.simpleMethod(); |
76 |
2
|
final int NON_POSITIVE = 0; |
77 |
2
|
try { |
78 |
2
|
expectLastCall().times(0, NON_POSITIVE); |
79 |
0
|
fail(); |
80 |
|
} catch (final IllegalArgumentException expected) { |
81 |
2
|
assertEquals("maximum must be >= 1", expected.getMessage()); |
82 |
|
} |
83 |
|
} |
84 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
85 |
2
|
@Test... |
86 |
|
public void setMinimumBiggerThanMaximum() { |
87 |
2
|
mock.simpleMethod(); |
88 |
2
|
try { |
89 |
2
|
expectLastCall().times(4, 3); |
90 |
0
|
fail(); |
91 |
|
} catch (final IllegalArgumentException expected) { |
92 |
2
|
assertEquals("minimum must be <= maximum", expected.getMessage()); |
93 |
|
} |
94 |
|
} |
95 |
|
} |