small mockito fixes

This commit is contained in:
eugenp 2014-11-15 11:26:24 +02:00
parent cc2bcb7894
commit b30bd3d27b
1 changed files with 7 additions and 7 deletions

View File

@ -14,8 +14,11 @@ import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class MockitoSpyTest { public class MockitoSpyTest {
@Spy
private List<String> aSpyList = new ArrayList<String>();
@Test @Test
public void whenSpyOnList_thenCorrect() { public void whenSpyingOnList_thenCorrect() {
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<String>();
final List<String> spyList = Mockito.spy(list); final List<String> spyList = Mockito.spy(list);
@ -28,11 +31,8 @@ public class MockitoSpyTest {
assertEquals(2, spyList.size()); assertEquals(2, spyList.size());
} }
@Spy
List<String> aSpyList = new ArrayList<String>();
@Test @Test
public void whenUseSpyAnnotation_thenCorrect() { public void whenUsingTheSpyAnnotation_thenObjectIsSpied() {
aSpyList.add("one"); aSpyList.add("one");
aSpyList.add("two"); aSpyList.add("two");
@ -55,7 +55,7 @@ public class MockitoSpyTest {
@Test @Test
public void whenCreateMock_thenCreated() { public void whenCreateMock_thenCreated() {
final List mockedList = Mockito.mock(List.class); final List<String> mockedList = Mockito.mock(ArrayList.class);
mockedList.add("one"); mockedList.add("one");
Mockito.verify(mockedList).add("one"); Mockito.verify(mockedList).add("one");
@ -65,7 +65,7 @@ public class MockitoSpyTest {
@Test @Test
public void whenCreateSpy_thenCreate() { public void whenCreateSpy_thenCreate() {
final List spyList = Mockito.spy(new ArrayList()); final List<String> spyList = Mockito.spy(new ArrayList<String>());
spyList.add("one"); spyList.add("one");
Mockito.verify(spyList).add("one"); Mockito.verify(spyList).add("one");