public class StubberImpl extends java.lang.Object implements Stubber
Modifier and Type | Field and Description |
---|---|
private java.util.List<Answer<?>> |
answers |
private Strictness |
strictness |
Constructor and Description |
---|
StubberImpl(Strictness strictness) |
Modifier and Type | Method and Description |
---|---|
Stubber |
doAnswer(Answer answer)
Use it for stubbing consecutive calls in
Mockito.doAnswer(Answer) style:
|
Stubber |
doCallRealMethod()
Use it for stubbing consecutive calls in
Mockito.doCallRealMethod() style. |
Stubber |
doNothing()
Use it for stubbing consecutive calls in
Mockito.doNothing() style:
|
Stubber |
doReturn(java.lang.Object toBeReturned)
Use it for stubbing consecutive calls in
Mockito.doReturn(Object) style. |
Stubber |
doReturn(java.lang.Object toBeReturned,
java.lang.Object... nextToBeReturned)
Use it for stubbing consecutive calls in
Mockito.doReturn(Object) style. |
private StubberImpl |
doReturnValues(java.lang.Object... toBeReturned) |
Stubber |
doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown)
Use it for stubbing consecutive calls in
Mockito.doThrow(Class) style:
|
Stubber |
doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown,
java.lang.Class<? extends java.lang.Throwable>... nextToBeThrown)
Use it for stubbing consecutive calls in
Mockito.doThrow(Class) style:
|
Stubber |
doThrow(java.lang.Throwable... toBeThrown)
Use it for stubbing consecutive calls in
Mockito.doThrow(Throwable[]) style:
|
<T> T |
when(T mock)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style
|
private final Strictness strictness
private final java.util.List<Answer<?>> answers
public StubberImpl(Strictness strictness)
public <T> T when(T mock)
Stubber
Example:
doThrow(new RuntimeException())
.when(mockedList).clear();
//following throws RuntimeException:
mockedList.clear();
Read more about those methods:
See examples in javadoc for Mockito
public Stubber doReturn(java.lang.Object toBeReturned)
BaseStubber
Mockito.doReturn(Object)
style.
See javadoc for Mockito.doReturn(Object)
doReturn
in interface BaseStubber
toBeReturned
- to be returned when the stubbed method is calledpublic Stubber doReturn(java.lang.Object toBeReturned, java.lang.Object... nextToBeReturned)
BaseStubber
Mockito.doReturn(Object)
style.
See javadoc for Mockito.doReturn(Object, Object...)
doReturn
in interface BaseStubber
toBeReturned
- to be returned when the stubbed method is callednextToBeReturned
- to be returned in consecutive calls when the stubbed method is calledprivate StubberImpl doReturnValues(java.lang.Object... toBeReturned)
public Stubber doThrow(java.lang.Throwable... toBeThrown)
BaseStubber
Mockito.doThrow(Throwable[])
style:
doThrow(new RuntimeException("one")).
doThrow(new RuntimeException("two"))
.when(mock).someVoidMethod();
See javadoc for Mockito.doThrow(Throwable[])
doThrow
in interface BaseStubber
toBeThrown
- to be thrown when the stubbed method is calledpublic Stubber doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown)
BaseStubber
Mockito.doThrow(Class)
style:
doThrow(RuntimeException.class).
doThrow(IllegalArgumentException.class)
.when(mock).someVoidMethod();
See javadoc for Mockito.doThrow(Class)
doThrow
in interface BaseStubber
toBeThrown
- exception class to be thrown when the stubbed method is calledpublic Stubber doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown, java.lang.Class<? extends java.lang.Throwable>... nextToBeThrown)
BaseStubber
Mockito.doThrow(Class)
style:
doThrow(RuntimeException.class).
doThrow(IllegalArgumentException.class)
.when(mock).someVoidMethod();
See javadoc for Mockito.doThrow(Class)
doThrow
in interface BaseStubber
toBeThrown
- exception class to be thrown when the stubbed method is callednextToBeThrown
- exception class next to be thrown when the stubbed method is calledpublic Stubber doNothing()
BaseStubber
Mockito.doNothing()
style:
doNothing().
doThrow(new RuntimeException("two"))
.when(mock).someVoidMethod();
See javadoc for Mockito.doNothing()
doNothing
in interface BaseStubber
public Stubber doAnswer(Answer answer)
BaseStubber
Mockito.doAnswer(Answer)
style:
doAnswer(answerOne).
doAnswer(answerTwo)
.when(mock).someVoidMethod();
See javadoc for Mockito.doAnswer(Answer)
doAnswer
in interface BaseStubber
answer
- to answer when the stubbed method is calledpublic Stubber doCallRealMethod()
BaseStubber
Mockito.doCallRealMethod()
style.
See javadoc for Mockito.doCallRealMethod()
doCallRealMethod
in interface BaseStubber