Package org.mockito.stubbing
Interface Stubber
-
- All Superinterfaces:
BaseStubber
@NotExtensible public interface Stubber extends BaseStubber
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() styleExample:
Also useful when stubbing consecutive calls:doThrow(new RuntimeException()).when(mockedList).clear(); //following throws RuntimeException: mockedList.clear();
Read more about those methods:doThrow(new RuntimeException("one")). doThrow(new RuntimeException("two")) .when(mock).someVoidMethod();
See examples in javadoc for
Mockito
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
when(T mock)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style-
Methods inherited from interface org.mockito.stubbing.BaseStubber
doAnswer, doCallRealMethod, doNothing, doReturn, doReturn, doThrow, doThrow, doThrow
-
-
-
-
Method Detail
-
when
<T> T when(T mock)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() styleExample:
Read more about those methods:doThrow(new RuntimeException()) .when(mockedList).clear(); //following throws RuntimeException: mockedList.clear();
See examples in javadoc for
Mockito
- Parameters:
mock
- The mock- Returns:
- select method for stubbing
-
-