Package | Description |
---|---|
org.mockito |
Mockito is a mock library for java - see
Mockito class for usage. |
org.mockito.configuration |
Mockito configuration utilities.
|
org.mockito.internal.configuration |
Mockito configuration.
|
org.mockito.internal.creation |
Mock object creation.
|
org.mockito.internal.creation.settings | |
org.mockito.internal.stubbing |
Stubbing logic.
|
org.mockito.internal.stubbing.answers |
Answers for stubbed calls.
|
org.mockito.internal.stubbing.defaultanswers |
Implementations of default Answers.
|
org.mockito.mock |
Mock settings related classes.
|
org.mockito.stubbing |
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<java.lang.Object> |
Mockito.CALLS_REAL_METHODS
Optional
Answer to be used with Mockito.mock(Class, Answer) |
private Answer<java.lang.Object> |
Answers.implementation |
static Answer<java.lang.Object> |
Mockito.RETURNS_DEEP_STUBS
Optional
Answer to be used with Mockito.mock(Class, Answer) . |
static Answer<java.lang.Object> |
Mockito.RETURNS_DEFAULTS
The default
Answer of every mock if the mock was not stubbed. |
static Answer<java.lang.Object> |
Mockito.RETURNS_MOCKS
Optional
Answer to be used with Mockito.mock(Class, Answer) |
static Answer<java.lang.Object> |
Mockito.RETURNS_SELF
Optional
Answer to be used with Mockito.mock(Class, Answer) . |
static Answer<java.lang.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 <T> Answer<T> |
AdditionalAnswers.answersWithDelay(long sleepyTime,
Answer<T> answer)
Returns an answer after a delay with a defined length.
|
static <A> Answer<java.lang.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<java.lang.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<java.lang.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<java.lang.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(java.lang.Object delegate)
An answer that directly forwards the calls to the delegate.
|
Answer<java.lang.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(java.util.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 |
---|---|
static <T> Answer<T> |
AdditionalAnswers.answersWithDelay(long sleepyTime,
Answer<T> answer)
Returns an answer after a delay with a defined length.
|
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(java.lang.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.BDDMyOngoingStubbing<T> |
BDDMockito.BDDOngoingStubbingImpl.will(Answer<?> answer) |
BDDMockito.BDDStubber |
BDDMockito.BDDStubber.will(Answer<?> answer)
See original
BaseStubber.doAnswer(Answer) |
BDDMockito.BDDStubber |
BDDMockito.BDDStubberImpl.will(Answer<?> 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.BDDMyOngoingStubbing<T> |
BDDMockito.BDDOngoingStubbingImpl.willAnswer(Answer<?> answer) |
BDDMockito.BDDStubber |
BDDMockito.BDDStubber.willAnswer(Answer<?> answer)
See original
BaseStubber.doAnswer(Answer) |
BDDMockito.BDDStubber |
BDDMockito.BDDStubberImpl.willAnswer(Answer<?> answer) |
Constructor and Description |
---|
Answers(Answer<java.lang.Object> implementation) |
Modifier and Type | Method and Description |
---|---|
Answer<java.lang.Object> |
DefaultMockitoConfiguration.getDefaultAnswer() |
Answer<java.lang.Object> |
IMockitoConfiguration.getDefaultAnswer()
Allows configuring the default answers of unstubbed invocations
|
Modifier and Type | Method and Description |
---|---|
Answer<java.lang.Object> |
GlobalConfiguration.getDefaultAnswer() |
Modifier and Type | Method and Description |
---|---|
Answer<java.lang.Object> |
MockSettingsImpl.getDefaultAnswer() |
Modifier and Type | Method and Description |
---|---|
MockSettings |
MockSettingsImpl.defaultAnswer(Answer defaultAnswer) |
Modifier and Type | Field and Description |
---|---|
protected Answer<java.lang.Object> |
CreationSettings.defaultAnswer |
Modifier and Type | Method and Description |
---|---|
Answer<java.lang.Object> |
CreationSettings.getDefaultAnswer() |
Modifier and Type | Class and Description |
---|---|
class |
StubbedInvocationMatcher |
Modifier and Type | Field and Description |
---|---|
private java.util.List<Answer<?>> |
StubberImpl.answers |
private java.util.Queue<Answer> |
StubbedInvocationMatcher.answers |
private java.util.List<Answer<?>> |
DoAnswerStyleStubbing.answers |
Modifier and Type | Method and Description |
---|---|
(package private) java.util.List<Answer<?>> |
DoAnswerStyleStubbing.getAnswers() |
Modifier and Type | Method and Description |
---|---|
void |
StubbedInvocationMatcher.addAnswer(Answer answer) |
StubbedInvocationMatcher |
InvocationContainerImpl.addAnswer(Answer answer,
boolean isConsecutive,
Strictness stubbingStrictness)
Adds new stubbed answer and returns the invocation matcher the answer was added to.
|
void |
InvocationContainerImpl.addAnswer(Answer answer,
Strictness stubbingStrictness) |
void |
InvocationContainerImpl.addConsecutiveAnswer(Answer answer) |
Stubber |
DefaultLenientStubber.doAnswer(Answer answer) |
Stubber |
StubberImpl.doAnswer(Answer answer) |
OngoingStubbing<T> |
BaseStubbing.then(Answer<?> answer) |
OngoingStubbing<T> |
ConsecutiveStubbing.thenAnswer(Answer<?> answer) |
OngoingStubbing<T> |
OngoingStubbingImpl.thenAnswer(Answer<?> answer) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
DoAnswerStyleStubbing.setAnswers(java.util.List<Answer<?>> answers,
Strictness stubbingStrictness) |
void |
InvocationContainerImpl.setAnswersForStubbing(java.util.List<Answer<?>> answers,
Strictness strictness)
Sets the answers declared with 'doAnswer' style.
|
Constructor and Description |
---|
StubbedInvocationMatcher(Answer answer,
MatchableInvocation invocation,
Strictness strictness) |
Modifier and Type | Class and Description |
---|---|
class |
AnswersWithDelay
Returns as the provided answer would return, after delaying the specified amount.
|
class |
CallsRealMethods
Optional Answer that adds partial mocking support
|
class |
ClonesArguments |
class |
DoesNothing |
class |
Returns |
class |
ReturnsArgumentAt
Returns the passed parameter identity at specified index.
|
class |
ReturnsElementsOf
Returns elements of the collection.
|
class |
ThrowsException
An answer that always throws the same throwable.
|
Modifier and Type | Field and Description |
---|---|
private Answer<java.lang.Object> |
AnswersWithDelay.answer |
Modifier and Type | Method and Description |
---|---|
static <T,A> Answer<T> |
AnswerFunctionalInterfaces.toAnswer(Answer1<T,A> answer)
Construct an answer from a two parameter answer interface
|
static <T,A,B> Answer<T> |
AnswerFunctionalInterfaces.toAnswer(Answer2<T,A,B> answer)
Construct an answer from a two parameter answer interface
|
static <T,A,B,C> Answer<T> |
AnswerFunctionalInterfaces.toAnswer(Answer3<T,A,B,C> answer)
Construct an answer from a three parameter answer interface
|
static <T,A,B,C,D> |
AnswerFunctionalInterfaces.toAnswer(Answer4<T,A,B,C,D> answer)
Construct an answer from a four parameter answer interface
|
static <T,A,B,C,D,E> |
AnswerFunctionalInterfaces.toAnswer(Answer5<T,A,B,C,D,E> answer)
Construct an answer from a five parameter answer interface
|
static <A> Answer<java.lang.Void> |
AnswerFunctionalInterfaces.toAnswer(VoidAnswer1<A> answer)
Construct an answer from a two parameter answer interface
|
static <A,B> Answer<java.lang.Void> |
AnswerFunctionalInterfaces.toAnswer(VoidAnswer2<A,B> answer)
Construct an answer from a two parameter answer interface
|
static <A,B,C> Answer<java.lang.Void> |
AnswerFunctionalInterfaces.toAnswer(VoidAnswer3<A,B,C> answer)
Construct an answer from a three parameter answer interface
|
static <A,B,C,D> Answer<java.lang.Void> |
AnswerFunctionalInterfaces.toAnswer(VoidAnswer4<A,B,C,D> answer)
Construct an answer from a four parameter answer interface
|
static <A,B,C,D,E> |
AnswerFunctionalInterfaces.toAnswer(VoidAnswer5<A,B,C,D,E> answer)
Construct an answer from a five parameter answer interface
|
Constructor and Description |
---|
AnswersWithDelay(long sleepyTime,
Answer<java.lang.Object> answer) |
Modifier and Type | Class and Description |
---|---|
class |
ForwardsInvocations
Internal answer to forward invocations on a real instance.
|
class |
GloballyConfiguredAnswer
Globally configured Answer.
|
class |
ReturnsDeepStubs
Returning deep stub implementation.
|
private static class |
ReturnsDeepStubs.DeeplyStubbedAnswer |
private static class |
ReturnsDeepStubs.ReturnsDeepStubsSerializationFallback |
class |
ReturnsEmptyValues
Default answer of every Mockito mock.
|
class |
ReturnsMocks |
class |
ReturnsMoreEmptyValues
It's likely this implementation will be used by default by every Mockito 3.0.0 mock.
|
class |
ReturnsSmartNulls
Optional Answer that can be used with
Mockito.mock(Class, Answer) |
private static class |
ReturnsSmartNulls.ThrowsSmartNullPointer |
class |
TriesToReturnSelf |
Modifier and Type | Field and Description |
---|---|
private Answer<java.lang.Object> |
ReturnsMoreEmptyValues.delegate |
private Answer<java.lang.Object> |
ReturnsMocks.delegate |
private Answer<java.lang.Object> |
ReturnsSmartNulls.delegate |
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 | Interface and Description |
---|---|
interface |
Stubbing
Stubbing declared on the mock object.
|
Modifier and Type | Method and Description |
---|---|
Stubber |
BaseStubber.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.
|