Testing / Mockito Interview Questions
Difference between doReturn and thenReturn.
No type safety: The parameter of doReturn is Object unlike thenReturn. So, there is no type checking in the compile time. When the type is mismatched in the runtime, there would be an WrongTypeOfReturnValue execption.
No side effect: The advantage of doReturn-when is no side effect. You can use doReturn-when to specify a return value on a spied object without making a side effect.
More Related questions...