Package | Description |
---|---|
org.mockito |
Mockito is a mock library for java - see Mockito class for for usage.
|
org.mockito.configuration |
Mockito configuration utilities
|
org.mockito.mock | |
org.mockito.stubbing |
External stubbing related classes
|
Modifier and Type | Class and Description |
---|---|
class |
Answers
Enumeration of pre-configured mock answers
|
Modifier and Type | Field and Description |
---|---|
static Answer<Object> |
Mockito.CALLS_REAL_METHODS
Optional
Answer to be used with Mockito.mock(Class, Answer) |
static Answer<Object> |
Mockito.RETURNS_DEEP_STUBS
Optional
Answer to be used with Mockito.mock(Class, Answer) . |
static Answer<Object> |
Mockito.RETURNS_DEFAULTS
The default
Answer of every mock if the mock was not stubbed. |
static Answer<Object> |
Mockito.RETURNS_MOCKS
Optional
Answer to be used with Mockito.mock(Class, Answer) |
static Answer<Object> |
Mockito.RETURNS_SELF
Optional
Answer to be used with Mockito.mock(Class, Answer) . |
static Answer<Object> |
Mockito.RETURNS_SMART_NULLS
Optional
Answer to be used with Mockito.mock(Class, Answer) . |
Modifier and Type | Method and Description |
---|---|
static <T,A> Answer<T> |
AdditionalAnswers.answer(Answer1<T,A> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <T,A,B> Answer<T> |
AdditionalAnswers.answer(Answer2<T,A,B> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <T,A,B,C> Answer<T> |
AdditionalAnswers.answer(Answer3<T,A,B,C> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <T,A,B,C,D> |
AdditionalAnswers.answer(Answer4<T,A,B,C,D> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <T,A,B,C,D,E> |
AdditionalAnswers.answer(Answer5<T,A,B,C,D,E> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <A> Answer<Void> |
AdditionalAnswers.answerVoid(VoidAnswer1<A> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <A,B> Answer<Void> |
AdditionalAnswers.answerVoid(VoidAnswer2<A,B> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <A,B,C> Answer<Void> |
AdditionalAnswers.answerVoid(VoidAnswer3<A,B,C> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <A,B,C,D> Answer<Void> |
AdditionalAnswers.answerVoid(VoidAnswer4<A,B,C,D> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <A,B,C,D,E> |
AdditionalAnswers.answerVoid(VoidAnswer5<A,B,C,D,E> answer)
Creates an answer from a functional interface - allows for a strongly typed answer to be created
ideally in Java 8
|
static <T> Answer<T> |
AdditionalAnswers.delegatesTo(Object delegate)
An answer that directly forwards the calls to the delegate.
|
Answer<Object> |
Answers.get()
Deprecated.
as of 2.1.0 Use the enum-constant directly, instead of this getter. This method will be removed in a future release
E.g. instead of Answers.CALLS_REAL_METHODS.get() use Answers.CALLS_REAL_METHODS . |
static <T> Answer<T> |
AdditionalAnswers.returnsArgAt(int position)
Returns the parameter of an invocation at the given position.
|
static <T> Answer<T> |
AdditionalAnswers.returnsElementsOf(Collection<?> elements)
Returns elements of the collection.
|
static <T> Answer<T> |
AdditionalAnswers.returnsFirstArg()
Returns the first parameter of an invocation.
|
static <T> Answer<T> |
AdditionalAnswers.returnsLastArg()
Returns the last parameter of an invocation.
|
static <T> Answer<T> |
AdditionalAnswers.returnsSecondArg()
Returns the second parameter of an invocation.
|
Modifier and Type | Method and Description |
---|---|
MockSettings |
MockSettings.defaultAnswer(Answer defaultAnswer)
Specifies default answers to interactions.
|
static Stubber |
Mockito.doAnswer(Answer answer)
Use
doAnswer() when you want to stub a void method with generic Answer . |
static <T> T |
Mockito.mock(Class<T> classToMock,
Answer defaultAnswer)
Creates mock with a specified strategy for its answers to interactions.
|
static BDDMockito.BDDStubber |
BDDMockito.will(Answer<?> answer)
see original
Mockito.doAnswer(Answer) |
BDDMockito.BDDMyOngoingStubbing<T> |
BDDMockito.BDDMyOngoingStubbing.will(Answer<?> answer)
See original
OngoingStubbing.then(Answer) |
BDDMockito.BDDStubber |
BDDMockito.BDDStubber.will(Answer<?> answer)
See original
Stubber.doAnswer(Answer) |
static BDDMockito.BDDStubber |
BDDMockito.willAnswer(Answer<?> answer)
see original
Mockito.doAnswer(Answer) |
BDDMockito.BDDMyOngoingStubbing<T> |
BDDMockito.BDDMyOngoingStubbing.willAnswer(Answer<?> answer)
See original
OngoingStubbing.thenAnswer(Answer) |
BDDMockito.BDDStubber |
BDDMockito.BDDStubber.willAnswer(Answer<?> answer)
See original
Stubber.doAnswer(Answer) |
Modifier and Type | Method and Description |
---|---|
Answer<Object> |
IMockitoConfiguration.getDefaultAnswer()
Allows configuring the default answers of unstubbed invocations
|
Answer<Object> |
DefaultMockitoConfiguration.getDefaultAnswer() |
Modifier and Type | Method and Description |
---|---|
Answer<?> |
MockCreationSettings.getDefaultAnswer()
the default answer for this mock, see
MockSettings.defaultAnswer(org.mockito.stubbing.Answer) . |
Modifier and Type | Method and Description |
---|---|
Stubber |
Stubber.doAnswer(Answer answer)
Use it for stubbing consecutive calls in
Mockito.doAnswer(Answer) style:
|
OngoingStubbing<T> |
OngoingStubbing.then(Answer<?> answer)
Sets a generic Answer for the method.
|
OngoingStubbing<T> |
OngoingStubbing.thenAnswer(Answer<?> answer)
Sets a generic Answer for the method.
|