| 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.junit.Before; |
| 11 |
|
import org.junit.Test; |
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
@author |
| 18 |
|
|
| 19 |
|
@SuppressWarnings("deprecation") |
|
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 6 |
Complexity Density: 0,22 |
|
| 20 |
|
public class UsageExpectAndDefaultReturnTest { |
| 21 |
|
private MockControl<IMethods> control; |
| 22 |
|
|
| 23 |
|
private IMethods mock; |
| 24 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 25 |
5
|
@Before... |
| 26 |
|
public void setup() { |
| 27 |
5
|
control = MockControl.createControl(IMethods.class); |
| 28 |
5
|
mock = control.getMock(); |
| 29 |
|
} |
| 30 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 31 |
1
|
@Test... |
| 32 |
|
public void booleanType() { |
| 33 |
1
|
control.expectAndDefaultReturn(mock.booleanReturningMethod(4), true); |
| 34 |
1
|
control.replay(); |
| 35 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 36 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 37 |
1
|
control.verify(); |
| 38 |
|
} |
| 39 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 40 |
1
|
@Test... |
| 41 |
|
public void longType() { |
| 42 |
1
|
control.expectAndDefaultReturn(mock.longReturningMethod(4), 12l); |
| 43 |
1
|
control.replay(); |
| 44 |
1
|
assertEquals(12l, mock.longReturningMethod(4)); |
| 45 |
1
|
assertEquals(12l, mock.longReturningMethod(4)); |
| 46 |
1
|
control.verify(); |
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 49 |
1
|
@Test... |
| 50 |
|
public void floatType() { |
| 51 |
1
|
control.expectAndDefaultReturn(mock.floatReturningMethod(4), 12f); |
| 52 |
1
|
control.replay(); |
| 53 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 54 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 55 |
1
|
control.verify(); |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 58 |
1
|
@Test... |
| 59 |
|
public void doubleType() { |
| 60 |
1
|
control.expectAndDefaultReturn(mock.doubleReturningMethod(4), 12.0); |
| 61 |
1
|
control.replay(); |
| 62 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 63 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 64 |
1
|
control.verify(); |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 67 |
1
|
@Test... |
| 68 |
|
public void objectType() { |
| 69 |
1
|
control.expectAndDefaultReturn(mock.objectReturningMethod(4), "12"); |
| 70 |
1
|
control.replay(); |
| 71 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 72 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 73 |
1
|
control.verify(); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
} |