jeudi 16 juillet 2015

stream() method is not working with Mockito spy

Code below:

 List<Object> list = spy(new LinkedList<>());
 list.stream().map(item -> item);

is not working, causing an exception during test:

Cannot call real method on java interface. Interface does not have any implementation!
Calling real methods is only possible when mocking concrete classes.
  //correct example:
  when(mockOfConcreteClass.doStuff()).thenCallRealMethod();

However, calling size() is working okay. What is wrong with stream() method? I am using Mockito 1.8.4 ver.

Aucun commentaire:

Enregistrer un commentaire