Complete the code to create a spy object for partial mocking.
List<String> list = Mockito.[1](new ArrayList<>());The @Spy annotation or Mockito.spy() method creates a spy object that allows partial mocking of real objects.
Complete the code to stub a method on a spy object.
Mockito.[1](spyList.size()).thenReturn(5);
Use when() to stub methods on spy objects for partial mocking.
Fix the error in stubbing a spy method to avoid calling the real method.
Mockito.[1](10).when(spyList).size();
Using doReturn() avoids calling the real method on a spy during stubbing, preventing side effects.
Fill both blanks to stub a spy method without calling the real method.
Mockito.[1](10).when(spyList).[2]();
Use doReturn(10).when(spyList).size() to stub the size() method on a spy without calling the real method.
Fill both blanks to verify a method call on a spy with a specific argument.
Mockito.[1](spyList).[2]("test");
Use verify(spyList).add("test") to check that the add method was called with argument "test" on the spy.