Package org.mockito.internal.stubbing
Class StubberImpl
- java.lang.Object
-
- org.mockito.internal.stubbing.StubberImpl
-
-
Constructor Summary
Constructors Constructor Description StubberImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stubber
doAnswer(Answer answer)
Use it for stubbing consecutive calls inMockito.doAnswer(Answer)
style:Stubber
doCallRealMethod()
Use it for stubbing consecutive calls inMockito.doCallRealMethod()
style.Stubber
doNothing()
Use it for stubbing consecutive calls inMockito.doNothing()
style:Stubber
doReturn(java.lang.Object toBeReturned)
Use it for stubbing consecutive calls inMockito.doReturn(Object)
style.Stubber
doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown)
Use it for stubbing consecutive calls inMockito.doThrow(Class)
style:Stubber
doThrow(java.lang.Throwable toBeThrown)
Use it for stubbing consecutive calls inMockito.doThrow(Throwable)
style:<T> T
when(T mock)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style
-
-
-
Method Detail
-
when
public <T> T when(T mock)
Description copied from interface:Stubber
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
-
doReturn
public Stubber doReturn(java.lang.Object toBeReturned)
Description copied from interface:Stubber
Use it for stubbing consecutive calls inMockito.doReturn(Object)
style.See javadoc for
Mockito.doReturn(Object)
-
doThrow
public Stubber doThrow(java.lang.Throwable toBeThrown)
Description copied from interface:Stubber
Use it for stubbing consecutive calls inMockito.doThrow(Throwable)
style:
See javadoc fordoThrow(new RuntimeException("one")). doThrow(new RuntimeException("two")) .when(mock).someVoidMethod();
Mockito.doThrow(Throwable)
-
doThrow
public Stubber doThrow(java.lang.Class<? extends java.lang.Throwable> toBeThrown)
Description copied from interface:Stubber
Use it for stubbing consecutive calls inMockito.doThrow(Class)
style:
See javadoc fordoThrow(RuntimeException.class). doThrow(IllegalArgumentException.class) .when(mock).someVoidMethod();
Mockito.doThrow(Class)
-
doNothing
public Stubber doNothing()
Description copied from interface:Stubber
Use it for stubbing consecutive calls inMockito.doNothing()
style:
See javadoc fordoNothing(). doThrow(new RuntimeException("two")) .when(mock).someVoidMethod();
Mockito.doNothing()
-
doAnswer
public Stubber doAnswer(Answer answer)
Description copied from interface:Stubber
Use it for stubbing consecutive calls inMockito.doAnswer(Answer)
style:
See javadoc fordoAnswer(answerOne). doAnswer(answerTwo) .when(mock).someVoidMethod();
Mockito.doAnswer(Answer)
-
doCallRealMethod
public Stubber doCallRealMethod()
Description copied from interface:Stubber
Use it for stubbing consecutive calls inMockito.doCallRealMethod()
style.See javadoc for
Mockito.doCallRealMethod()
- Specified by:
doCallRealMethod
in interfaceStubber
- Returns:
- stubber - to select a method for stubbing
-
-