File tree Expand file tree Collapse file tree
mockito/src/test/java/org/baeldung/mockito Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414@ RunWith (MockitoJUnitRunner .class )
1515public 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" );
You can’t perform that action at this time.
0 commit comments