Package org.mockito.stubbing
Interface BaseStubber
-
- All Known Subinterfaces:
LenientStubber,Stubber
@NotExtensible public interface BaseStubber
Base interface for stubbing consecutive method calls withMockito.doReturn(Object)syntax. This interface is needed so that we can reuse the same hierarchy in subinterfaces.- Since:
- 2.20.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StubberdoAnswer(Answer answer)Use it for stubbing consecutive calls inMockito.doAnswer(Answer)style:StubberdoCallRealMethod()Use it for stubbing consecutive calls inMockito.doCallRealMethod()style.StubberdoNothing()Use it for stubbing consecutive calls inMockito.doNothing()style:StubberdoReturn(Object toBeReturned)Use it for stubbing consecutive calls inMockito.doReturn(Object)style.StubberdoReturn(Object toBeReturned, Object... nextToBeReturned)Use it for stubbing consecutive calls inMockito.doReturn(Object)style.StubberdoThrow(Class<? extends Throwable> toBeThrown)Use it for stubbing consecutive calls inMockito.doThrow(Class)style:StubberdoThrow(Class<? extends Throwable> toBeThrown, Class<? extends Throwable>... nextToBeThrown)Use it for stubbing consecutive calls inMockito.doThrow(Class)style:StubberdoThrow(Throwable... toBeThrown)Use it for stubbing consecutive calls inMockito.doThrow(Throwable[])style:
-
-
-
Method Detail
-
doThrow
Stubber doThrow(Throwable... toBeThrown)
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[])- Parameters:
toBeThrown- to be thrown when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doThrow
Stubber doThrow(Class<? extends Throwable> toBeThrown)
Use it for stubbing consecutive calls inMockito.doThrow(Class)style:
See javadoc fordoThrow(RuntimeException.class). doThrow(IllegalArgumentException.class) .when(mock).someVoidMethod();Mockito.doThrow(Class)- Parameters:
toBeThrown- exception class to be thrown when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
- Since:
- 2.1.0
-
doThrow
Stubber doThrow(Class<? extends Throwable> toBeThrown, Class<? extends Throwable>... nextToBeThrown)
Use it for stubbing consecutive calls inMockito.doThrow(Class)style:
See javadoc fordoThrow(RuntimeException.class). doThrow(IllegalArgumentException.class) .when(mock).someVoidMethod();Mockito.doThrow(Class)- 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
- Since:
- 2.1.0
-
doAnswer
Stubber doAnswer(Answer answer)
Use it for stubbing consecutive calls inMockito.doAnswer(Answer)style:
See javadoc fordoAnswer(answerOne). doAnswer(answerTwo) .when(mock).someVoidMethod();Mockito.doAnswer(Answer)- Parameters:
answer- to answer when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doNothing
Stubber doNothing()
Use it for stubbing consecutive calls inMockito.doNothing()style:
See javadoc fordoNothing(). doThrow(new RuntimeException("two")) .when(mock).someVoidMethod();Mockito.doNothing()- Returns:
- stubber - to select a method for stubbing
-
doReturn
Stubber doReturn(Object toBeReturned)
Use it for stubbing consecutive calls inMockito.doReturn(Object)style.See javadoc for
Mockito.doReturn(Object)- Parameters:
toBeReturned- to be returned when the stubbed method is called- Returns:
- stubber - to select a method for stubbing
-
doReturn
Stubber doReturn(Object toBeReturned, Object... nextToBeReturned)
Use it for stubbing consecutive calls inMockito.doReturn(Object)style.See javadoc for
Mockito.doReturn(Object, Object...)- 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
Stubber doCallRealMethod()
Use it for stubbing consecutive calls inMockito.doCallRealMethod()style.See javadoc for
Mockito.doCallRealMethod()- Returns:
- stubber - to select a method for stubbing
-
-