mockitoMocking consecutive calls to a void return method


The Mockito docs have an excellent example of how to provide a sequence of answers for multiple calls to a mock. However, they don't cover how to do that for a method that returns void, other than noting that stubbing void methods require using the do family of methods.


Remember, for non-void methods, the when(mock.method()).thenThrow().thenReturn() version (see docs) is preferred because it is argument type-safe and more readable.