Prev Next

Testing / Mockito Interview Questions

How do you create a stub for a method returning void?

Void methods can be used with Mockito's doNothing(), doThrow(), and doAnswer() methods.

doNothing().when(someObject).someMethod(anyObject());

Mockito.doThrow(new Exception()).when(instance).methodName();

More Related questions...

Show more question and Answers...


Comments & Discussions