Skip to content

Commit b30bd3d

Browse files
author
eugenp
committed
small mockito fixes
1 parent cc2bcb7 commit b30bd3d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

mockito/src/test/java/org/baeldung/mockito/MockitoSpyTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
@RunWith(MockitoJUnitRunner.class)
1515
public class MockitoSpyTest {
1616

17+
@Spy
18+
private List<String> aSpyList = new ArrayList<String>();
19+
1720
@Test
18-
public void whenSpyOnList_thenCorrect() {
21+
public void whenSpyingOnList_thenCorrect() {
1922
final List<String> list = new ArrayList<String>();
2023
final List<String> spyList = Mockito.spy(list);
2124

@@ -28,11 +31,8 @@ public void whenSpyOnList_thenCorrect() {
2831
assertEquals(2, spyList.size());
2932
}
3033

31-
@Spy
32-
List<String> aSpyList = new ArrayList<String>();
33-
3434
@Test
35-
public void whenUseSpyAnnotation_thenCorrect() {
35+
public void whenUsingTheSpyAnnotation_thenObjectIsSpied() {
3636
aSpyList.add("one");
3737
aSpyList.add("two");
3838

@@ -55,7 +55,7 @@ public void whenStubASpy_thenStubbed() {
5555

5656
@Test
5757
public void whenCreateMock_thenCreated() {
58-
final List mockedList = Mockito.mock(List.class);
58+
final List<String> mockedList = Mockito.mock(ArrayList.class);
5959

6060
mockedList.add("one");
6161
Mockito.verify(mockedList).add("one");
@@ -65,7 +65,7 @@ public void whenCreateMock_thenCreated() {
6565

6666
@Test
6767
public void whenCreateSpy_thenCreate() {
68-
final List spyList = Mockito.spy(new ArrayList());
68+
final List<String> spyList = Mockito.spy(new ArrayList<String>());
6969

7070
spyList.add("one");
7171
Mockito.verify(spyList).add("one");

0 commit comments

Comments
 (0)