mockito when-thenReturn vs doReturn-when

when(...) thenReturn(...) makes a real method call just before it is mocked. So if the called method throws an Exception you have to deal with it / mock it etc. Of course you still get your result (what you define in thenReturn(...) )

doReturn(...) when(...) does not call the method at all.

No comments:

Post a Comment