I want to use Mockito to test the (simplified) code below. I don\'t know how to tell Mockito to fail the first time, then succeed the second time.
for(int i = 1;
Since the comment that relates to this is hard to read, I'll add a formatted answer.
If you are trying to do this with a void
function that just throws an exception, followed by a no behavior step, then you would do something like this:
Mockito.doThrow(new Exception("MESSAGE"))
.doNothing()
.when(mockService).method(eq());