Strony

2018-02-14

How to make mock to void methods with Mockito

Mock not void method:
Mockito.when(jsonResponseValidator.validate(any(DefaultResponse.class))).thenCallRealMethod()
Mock void method:
Mockito.doCallRealMethod().when(jsonResponseValidator).validate(any(DefaultResponse.class));
You can use any of the doReturn(), doThrow(), doAnswer(),doNothing(), doCallRealMethod() family of methods. source: Mockito API

Brak komentarzy:

Prześlij komentarz