| 1 |
|
package org.easymock.tests2; |
| 2 |
|
|
| 3 |
|
import org.easymock.IMocksControl; |
| 4 |
|
import org.easymock.tests.IMethods; |
| 5 |
|
import org.junit.Test; |
| 6 |
|
|
| 7 |
|
import static org.easymock.EasyMock.*; |
| 8 |
|
import static org.junit.Assert.*; |
| 9 |
|
|
|
|
|
| 97,6% |
Uncovered Elements: 1 (42) |
Complexity: 10 |
Complexity Density: 0,27 |
|
| 10 |
|
public class NameTest { |
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0,25 |
1
PASS
|
|
| 11 |
1
|
@Test... |
| 12 |
|
public void nameForMock() { |
| 13 |
1
|
IMethods mock = createMock("mock", IMethods.class); |
| 14 |
1
|
mock.simpleMethod(); |
| 15 |
1
|
replay(mock); |
| 16 |
1
|
try { |
| 17 |
1
|
verify(mock); |
| 18 |
|
} catch (AssertionError expected) { |
| 19 |
1
|
String actualMessage = expected.getMessage(); |
| 20 |
1
|
String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0"; |
| 21 |
1
|
assertEquals(expectedMessage, actualMessage); |
| 22 |
|
} |
| 23 |
|
} |
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0,25 |
1
PASS
|
|
| 24 |
1
|
@Test... |
| 25 |
|
public void nameForStrictMock() { |
| 26 |
1
|
IMethods mock = createStrictMock("mock", IMethods.class); |
| 27 |
1
|
mock.simpleMethod(); |
| 28 |
1
|
replay(mock); |
| 29 |
1
|
try { |
| 30 |
1
|
verify(mock); |
| 31 |
|
} catch (AssertionError expected) { |
| 32 |
1
|
String actualMessage = expected.getMessage(); |
| 33 |
1
|
String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0"; |
| 34 |
1
|
assertEquals(expectedMessage, actualMessage); |
| 35 |
|
} |
| 36 |
|
} |
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0,25 |
1
PASS
|
|
| 37 |
1
|
@Test... |
| 38 |
|
public void nameForNiceMock() { |
| 39 |
1
|
IMethods mock = createNiceMock("mock", IMethods.class); |
| 40 |
1
|
mock.simpleMethod(); |
| 41 |
1
|
replay(mock); |
| 42 |
1
|
try { |
| 43 |
1
|
verify(mock); |
| 44 |
|
} catch (AssertionError expected) { |
| 45 |
1
|
String actualMessage = expected.getMessage(); |
| 46 |
1
|
String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0"; |
| 47 |
1
|
assertEquals(expectedMessage, actualMessage); |
| 48 |
|
} |
| 49 |
|
} |
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0,22 |
1
PASS
|
|
| 50 |
1
|
@Test... |
| 51 |
|
public void nameForMocksControl() { |
| 52 |
1
|
IMocksControl control = createControl(); |
| 53 |
1
|
IMethods mock = control.createMock("mock", IMethods.class); |
| 54 |
1
|
mock.simpleMethod(); |
| 55 |
1
|
replay(mock); |
| 56 |
1
|
try { |
| 57 |
1
|
verify(mock); |
| 58 |
|
} catch (AssertionError expected) { |
| 59 |
1
|
String actualMessage = expected.getMessage(); |
| 60 |
1
|
String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0"; |
| 61 |
1
|
assertEquals(expectedMessage, actualMessage); |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 65 |
1
|
@Test... |
| 66 |
|
public void shouldThrowIllegalArgumentExceptionIfNameIsNoValidJavaIdentifier() { |
| 67 |
1
|
try { |
| 68 |
1
|
createMock("no-valid-java-identifier", IMethods.class); |
| 69 |
0
|
throw new AssertionError(); |
| 70 |
|
} catch (IllegalArgumentException expected) { |
| 71 |
1
|
assertEquals("'no-valid-java-identifier' is not a valid Java identifier.", expected.getMessage()); |
| 72 |
|
} |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
} |