nazerke
4/11/2019 - 4:22 AM

spying

List<String> liveList = new LinkedList<String>();
List<String> spyList = Mockito.spy(liveList);

//This will result in an IndexOutOfBoundsException !!! 
//This would work if it was mock, not a spy. 
//For this to work with spy, first need to add element to list
Mockito.when(spyList.get(0)).thenReturn("A string result");