June 2014
Intermediate to advanced
284 pages
6h 9m
English
In this recipe, we will stub a void method that doesn't return a value. The trick with void methods is that Mockito assumes that they do nothing by default, so there is no need to explicitly stub them (although you may do it).
If you do not want your void method to execute logic, you need to perform the following steps:
BDDMockito.willNothing().given(mock).methodToStub(), or in the standard way, call Mockito.doNothing().when(mock).methodToStub().given(...) or when(...) method, you have to provide the mock object (and ...Read now
Unlock full access