|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mockito.internal.stubbing.StubberImpl
public class StubberImpl
Constructor Summary | |
---|---|
StubberImpl()
|
Method Summary | ||
---|---|---|
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 |
doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown)
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:
|
|
|
when(T mock)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StubberImpl()
Method Detail |
---|
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
when
in interface Stubber
mock
- The mock
public Stubber doReturn(java.lang.Object toBeReturned)
Stubber
Mockito.doReturn(Object)
style.
See javadoc for Mockito.doReturn(Object)
doReturn
in interface Stubber
toBeReturned
- to be returned when the stubbed method is called
public Stubber doThrow(java.lang.Throwable toBeThrown)
Stubber
Mockito.doThrow(Throwable)
style:
doThrow(new RuntimeException("one")).
doThrow(new RuntimeException("two"))
.when(mock).someVoidMethod();
See javadoc for Mockito.doThrow(Throwable)
doThrow
in interface Stubber
toBeThrown
- to be thrown when the stubbed method is called
public Stubber doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown)
Stubber
Mockito.doThrow(Class)
style:
doThrow(RuntimeException.class).
doThrow(IllegalArgumentException.class)
.when(mock).someVoidMethod();
See javadoc for Mockito.doThrow(Class)
doThrow
in interface Stubber
toBeThrown
- exception class to be thrown when the stubbed method is called
public Stubber doNothing()
Stubber
Mockito.doNothing()
style:
doNothing().
doThrow(new RuntimeException("two"))
.when(mock).someVoidMethod();
See javadoc for Mockito.doNothing()
doNothing
in interface Stubber
public Stubber doAnswer(Answer answer)
Stubber
Mockito.doAnswer(Answer)
style:
doAnswer(answerOne).
doAnswer(answerTwo)
.when(mock).someVoidMethod();
See javadoc for Mockito.doAnswer(Answer)
doAnswer
in interface Stubber
answer
- to answer when the stubbed method is called
public Stubber doCallRealMethod()
Stubber
Mockito.doCallRealMethod()
style.
See javadoc for Mockito.doCallRealMethod()
doCallRealMethod
in interface Stubber
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |