Package org.mockito.internal.stubbing
Class DefaultLenientStubber
java.lang.Object
org.mockito.internal.stubbing.DefaultLenientStubber
- All Implemented Interfaces:
BaseStubber
,LenientStubber
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionUse it for stubbing consecutive calls inMockito.doAnswer(Answer)
style:Use it for stubbing consecutive calls inMockito.doCallRealMethod()
style.Use it for stubbing consecutive calls inMockito.doNothing()
style:Use it for stubbing consecutive calls inMockito.doReturn(Object)
style.Use it for stubbing consecutive calls inMockito.doReturn(Object)
style.Use it for stubbing consecutive calls inMockito.doThrow(Class)
style:Use it for stubbing consecutive calls inMockito.doThrow(Class)
style:Use it for stubbing consecutive calls inMockito.doThrow(Throwable[])
style:private static Stubber
stubber()
<T> OngoingStubbing
<T> when
(T methodCall) Allows declaring the method to stub.
-
Field Details
-
MOCKITO_CORE
-
-
Constructor Details
-
DefaultLenientStubber
public DefaultLenientStubber()
-
-
Method Details
-
doThrow
Description copied from interface:BaseStubber
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[])
- Specified by:
doThrow
in interfaceBaseStubber
- Parameters:
toBeThrown
- to be thrown when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doThrow
Description copied from interface:BaseStubber
Use it for stubbing consecutive calls inMockito.doThrow(Class)
style:
See javadoc fordoThrow(RuntimeException.class). doThrow(IllegalArgumentException.class) .when(mock).someVoidMethod();
Mockito.doThrow(Class)
- Specified by:
doThrow
in interfaceBaseStubber
- Parameters:
toBeThrown
- exception class to be thrown when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doThrow
public Stubber doThrow(Class<? extends Throwable> toBeThrown, Class<? extends Throwable>... nextToBeThrown) Description copied from interface:BaseStubber
Use it for stubbing consecutive calls inMockito.doThrow(Class)
style:
See javadoc fordoThrow(RuntimeException.class). doThrow(IllegalArgumentException.class) .when(mock).someVoidMethod();
Mockito.doThrow(Class)
- Specified by:
doThrow
in interfaceBaseStubber
- Parameters:
toBeThrown
- exception class to be thrown when the stubbed method is callednextToBeThrown
- exception class next to be thrown when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doAnswer
Description copied from interface:BaseStubber
Use it for stubbing consecutive calls inMockito.doAnswer(Answer)
style:
See javadoc fordoAnswer(answerOne). doAnswer(answerTwo) .when(mock).someVoidMethod();
Mockito.doAnswer(Answer)
- Specified by:
doAnswer
in interfaceBaseStubber
- Parameters:
answer
- to answer when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doNothing
Description copied from interface:BaseStubber
Use it for stubbing consecutive calls inMockito.doNothing()
style:
See javadoc fordoNothing(). doThrow(new RuntimeException("two")) .when(mock).someVoidMethod();
Mockito.doNothing()
- Specified by:
doNothing
in interfaceBaseStubber
- Returns:
- stubber - to select a method for stubbing
-
doReturn
Description copied from interface:BaseStubber
Use it for stubbing consecutive calls inMockito.doReturn(Object)
style.See javadoc for
Mockito.doReturn(Object)
- Specified by:
doReturn
in interfaceBaseStubber
- Parameters:
toBeReturned
- to be returned when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doReturn
Description copied from interface:BaseStubber
Use it for stubbing consecutive calls inMockito.doReturn(Object)
style.See javadoc for
Mockito.doReturn(Object, Object...)
- Specified by:
doReturn
in interfaceBaseStubber
- Parameters:
toBeReturned
- to be returned when the stubbed method is callednextToBeReturned
- to be returned in consecutive calls when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doCallRealMethod
Description copied from interface:BaseStubber
Use it for stubbing consecutive calls inMockito.doCallRealMethod()
style.See javadoc for
Mockito.doCallRealMethod()
- Specified by:
doCallRealMethod
in interfaceBaseStubber
- Returns:
- stubber - to select a method for stubbing
-
when
Description copied from interface:LenientStubber
Allows declaring the method to stub. SeeMockito.when(Object)
. Needed for classic stubbing with when().then()- Specified by:
when
in interfaceLenientStubber
-
stubber
-