1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.easymock.tests2; |
18 |
|
|
19 |
|
import static org.easymock.EasyMock.*; |
20 |
|
import static org.junit.Assert.*; |
21 |
|
|
22 |
|
import org.easymock.EasyMockSupport; |
23 |
|
import org.easymock.tests.IMethods; |
24 |
|
import org.junit.Rule; |
25 |
|
import org.junit.Test; |
26 |
|
|
|
|
| 91,7% |
Uncovered Elements: 1 (12) |
Complexity: 3 |
Complexity Density: 0,3 |
|
27 |
|
public class DependencyTest extends EasyMockSupport { |
28 |
|
|
29 |
|
@Rule |
30 |
|
public FilteringRule rule = new FilteringRule("net.sf.cglib", "org.objenesis"); |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
32 |
2
|
@Test... |
33 |
|
public void testInterfaceMocking() { |
34 |
2
|
final IMethods mock = createMock(IMethods.class); |
35 |
2
|
expect(mock.booleanReturningMethod(1)).andReturn(true); |
36 |
2
|
replayAll(); |
37 |
2
|
assertTrue(mock.booleanReturningMethod(1)); |
38 |
2
|
verifyAll(); |
39 |
|
} |
40 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
41 |
2
|
@Test... |
42 |
|
public void testClassMocking() { |
43 |
2
|
try { |
44 |
2
|
final DependencyTest mock = createMock(DependencyTest.class); |
45 |
0
|
fail("Should throw an exception due to a NoClassDefFoundError"); |
46 |
|
} catch (final RuntimeException e) { |
47 |
2
|
assertEquals("Class mocking requires to have cglib and objenesis librairies in the classpath", e |
48 |
|
.getMessage()); |
49 |
2
|
assertTrue(e.getCause() instanceof NoClassDefFoundError); |
50 |
|
} |
51 |
|
} |
52 |
|
} |