@NotExtensible public interface Stubber extends BaseStubber
Example:
doThrow(new RuntimeException()).when(mockedList).clear();
//following throws RuntimeException:
mockedList.clear();
Also useful when stubbing consecutive calls:
doThrow(new RuntimeException("one")).
doThrow(new RuntimeException("two"))
.when(mock).someVoidMethod();
Read more about those methods:
See examples in javadoc for Mockito
Modifier and Type | Method and Description |
---|---|
<T> T |
when(T mock)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style
|
doAnswer, doCallRealMethod, doNothing, doReturn, doReturn, doThrow, doThrow, doThrow
<T> T when(T mock)
Example:
doThrow(new RuntimeException())
.when(mockedList).clear();
//following throws RuntimeException:
mockedList.clear();
Read more about those methods:
See examples in javadoc for Mockito
mock
- The mock