Uses of Interface
org.mockito.stubbing.Answer
Packages that use Answer
Package
Description
Mockito is a mock library for java - see
Mockito
class for usage.Mockito configuration utilities.
Mockito configuration.
Mock object creation.
ByteBuddy related stuff.
Stubbing logic.
Answers for stubbed calls.
Implementations of default Answers.
Mock settings related classes.
Stubbing related classes.
-
Uses of Answer in org.mockito
Classes in org.mockito that implement AnswerFields in org.mockito declared as AnswerModifier and TypeFieldDescriptionMockito.CALLS_REAL_METHODS
OptionalAnswer
to be used withMockito.mock(Class, Answer)
Answers.implementation
Mockito.RETURNS_DEEP_STUBS
OptionalAnswer
to be used withMockito.mock(Class, Answer)
.Mockito.RETURNS_DEFAULTS
The defaultAnswer
of every mock if the mock was not stubbed.Mockito.RETURNS_MOCKS
OptionalAnswer
to be used withMockito.mock(Class, Answer)
Mockito.RETURNS_SELF
OptionalAnswer
to be used withMockito.mock(Class, Answer)
.Mockito.RETURNS_SMART_NULLS
OptionalAnswer
to be used withMockito.mock(Class, Answer)
.Methods in org.mockito that return AnswerModifier and TypeMethodDescriptionstatic <T,
A> Answer <T> Creates an answer from a functional interface - allows for a strongly typed answer to be created ideally in Java 8static <T,
A, B> Answer <T> Creates an answer from a functional interface - allows for a strongly typed answer to be created ideally in Java 8static <T,
A, B, C>
Answer<T> Creates an answer from a functional interface - allows for a strongly typed answer to be created ideally in Java 8static <T,
A, B, C, D>
Answer<T> Creates an answer from a functional interface - allows for a strongly typed answer to be created ideally in Java 8static <T,
A, B, C, D, E>
Answer<T> Creates an answer from a functional interface - allows for a strongly typed answer to be created ideally in Java 8static <T,
A, B, C, D, E, F>
Answer<T> Creates an answer from a functional interface - allows for a strongly typed answer to be created idiomatically in Java 8static <T> Answer
<T> AdditionalAnswers.answersWithDelay
(long sleepyTime, Answer<T> answer) Returns an answer after a delay with a defined length.AdditionalAnswers.answerVoid
(VoidAnswer1<A> answer) Creates an answer from a functional interface - allows for a strongly typed answer to be created ideally in Java 8AdditionalAnswers.answerVoid
(VoidAnswer2<A, B> answer) Creates an answer from a functional interface - allows for a strongly typed answer to be created ideally in Java 8AdditionalAnswers.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 8AdditionalAnswers.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 8AdditionalAnswers.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 8AdditionalAnswers.answerVoid
(VoidAnswer6<A, B, C, D, E, F> answer) Creates an answer from a functional interface - allows for a strongly typed answer to be created idiomatically in Java 8static <T> Answer
<T> AdditionalAnswers.delegatesTo
(Object delegate) An answer that directly forwards the calls to the delegate.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.Methods in org.mockito with parameters of type AnswerModifier and TypeMethodDescriptionstatic <T> Answer
<T> AdditionalAnswers.answersWithDelay
(long sleepyTime, Answer<T> answer) Returns an answer after a delay with a defined length.MockSettings.defaultAnswer
(Answer defaultAnswer) Specifies default answers to interactions.static Stubber
UsedoAnswer()
when you want to stub a void method with genericAnswer
.static <T> T
Creates mock with a specified strategy for its answers to interactions.static <T> T
Creates a mock object of the requested class or interface with the given default answer.static <T> MockedConstruction
<T> Mockito.mockConstructionWithAnswer
(Class<T> classToMock, Answer defaultAnswer, Answer... additionalAnswers) Creates a thread-local mock controller for all constructions of the given class.static <T> MockedStatic
<T> Mockito.mockStatic
(Class<T> classToMock, Answer defaultAnswer) Creates a thread-local mock controller for all static methods of the given class or interface.See originalOngoingStubbing.then(Answer)
See originalBaseStubber.doAnswer(Answer)
static BDDMockito.BDDStubber
see originalMockito.doAnswer(Answer)
BDDMockito.BDDMyOngoingStubbing.willAnswer
(Answer<?> answer) See originalOngoingStubbing.thenAnswer(Answer)
BDDMockito.BDDOngoingStubbingImpl.willAnswer
(Answer<?> answer) BDDMockito.BDDStubber.willAnswer
(Answer<?> answer) See originalBaseStubber.doAnswer(Answer)
BDDMockito.BDDStubberImpl.willAnswer
(Answer<?> answer) static BDDMockito.BDDStubber
BDDMockito.willAnswer
(Answer<?> answer) see originalMockito.doAnswer(Answer)
Constructors in org.mockito with parameters of type Answer -
Uses of Answer in org.mockito.configuration
Methods in org.mockito.configuration that return AnswerModifier and TypeMethodDescriptionDefaultMockitoConfiguration.getDefaultAnswer()
IMockitoConfiguration.getDefaultAnswer()
Allows configuring the default answers of un-stubbed invocations -
Uses of Answer in org.mockito.internal.configuration
Methods in org.mockito.internal.configuration that return Answer -
Uses of Answer in org.mockito.internal.creation
Methods in org.mockito.internal.creation that return AnswerMethods in org.mockito.internal.creation with parameters of type Answer -
Uses of Answer in org.mockito.internal.creation.bytebuddy
Fields in org.mockito.internal.creation.bytebuddy declared as AnswerMethods in org.mockito.internal.creation.bytebuddy with parameters of type AnswerModifier and TypeMethodDescriptionstatic <T> MockFeatures
<T> MockFeatures.withMockFeatures
(Class<T> mockedType, Set<Class<?>> interfaces, SerializableMode serializableMode, boolean stripAnnotations, Answer defaultAnswer) Constructors in org.mockito.internal.creation.bytebuddy with parameters of type AnswerModifierConstructorDescriptionprivate
MockFeatures
(Class<T> mockedType, Set<Class<?>> interfaces, SerializableMode serializableMode, boolean stripAnnotations, Answer defaultAnswer) -
Uses of Answer in org.mockito.internal.creation.settings
Fields in org.mockito.internal.creation.settings declared as AnswerMethods in org.mockito.internal.creation.settings that return Answer -
Uses of Answer in org.mockito.internal.stubbing
Classes in org.mockito.internal.stubbing that implement AnswerFields in org.mockito.internal.stubbing with type parameters of type AnswerModifier and TypeFieldDescriptionDoAnswerStyleStubbing.answers
StubbedInvocationMatcher.answers
StubberImpl.answers
Methods in org.mockito.internal.stubbing that return AnswerMethods in org.mockito.internal.stubbing that return types with arguments of type AnswerMethods in org.mockito.internal.stubbing with parameters of type AnswerModifier and TypeMethodDescriptionInvocationContainerImpl.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
void
InvocationContainerImpl.addConsecutiveAnswer
(Answer<?> answer) ConsecutiveStubbing.thenAnswer
(Answer<?> answer) OngoingStubbingImpl.thenAnswer
(Answer<?> answer) Method parameters in org.mockito.internal.stubbing with type arguments of type AnswerModifier and TypeMethodDescription(package private) void
DoAnswerStyleStubbing.setAnswers
(List<Answer<?>> answers, Strictness stubbingStrictness) void
InvocationContainerImpl.setAnswersForStubbing
(List<Answer<?>> answers, Strictness strictness) Sets the answers declared with 'doAnswer' style.Constructors in org.mockito.internal.stubbing with parameters of type AnswerModifierConstructorDescriptionStubbedInvocationMatcher
(Answer answer, MatchableInvocation invocation, Strictness strictness) -
Uses of Answer in org.mockito.internal.stubbing.answers
Classes in org.mockito.internal.stubbing.answers that implement AnswerModifier and TypeClassDescriptionclass
class
Returns as the provided answer would return, after delaying the specified amount.class
Optional Answer that adds partial mocking supportclass
class
class
class
Returns the passed parameter identity at specified index.class
Returns elements of the collection.class
An answer that always throws the same throwable.class
Fields in org.mockito.internal.stubbing.answers declared as AnswerMethods in org.mockito.internal.stubbing.answers that return AnswerModifier and TypeMethodDescriptionstatic <T,
A> Answer <T> Construct an answer from a two parameter answer interfacestatic <T,
A, B> Answer <T> Construct an answer from a two parameter answer interfacestatic <T,
A, B, C>
Answer<T> Construct an answer from a three parameter answer interfacestatic <T,
A, B, C, D>
Answer<T> Construct an answer from a four parameter answer interfacestatic <T,
A, B, C, D, E>
Answer<T> Construct an answer from a five parameter answer interfacestatic <T,
A, B, C, D, E, F>
Answer<T> Construct an answer from a six parameter answer interfaceAnswerFunctionalInterfaces.toAnswer
(VoidAnswer1<A> answer) Construct an answer from a two parameter answer interfaceAnswerFunctionalInterfaces.toAnswer
(VoidAnswer2<A, B> answer) Construct an answer from a two parameter answer interfaceAnswerFunctionalInterfaces.toAnswer
(VoidAnswer3<A, B, C> answer) Construct an answer from a three parameter answer interfaceAnswerFunctionalInterfaces.toAnswer
(VoidAnswer4<A, B, C, D> answer) Construct an answer from a four parameter answer interfaceAnswerFunctionalInterfaces.toAnswer
(VoidAnswer5<A, B, C, D, E> answer) Construct an answer from a five parameter answer interfaceAnswerFunctionalInterfaces.toAnswer
(VoidAnswer6<A, B, C, D, E, F> answer) Construct an answer from a five parameter answer interfaceConstructors in org.mockito.internal.stubbing.answers with parameters of type Answer -
Uses of Answer in org.mockito.internal.stubbing.defaultanswers
Classes in org.mockito.internal.stubbing.defaultanswers that implement AnswerModifier and TypeClassDescriptionclass
Internal answer to forward invocations on a real instance.class
Globally configured Answer.class
Returning deep stub implementation.private static class
private static class
class
Default answer of every Mockito mock.class
class
It's likely this implementation will be used by default by every Mockito 4.0.0 mock.class
Optional Answer that can be used withMockito.mock(Class, Answer)
private static class
class
Fields in org.mockito.internal.stubbing.defaultanswers declared as Answer -
Uses of Answer in org.mockito.mock
Methods in org.mockito.mock that return AnswerModifier and TypeMethodDescriptionAnswer
<?> MockCreationSettings.getDefaultAnswer()
the default answer for this mock, seeMockSettings.defaultAnswer(org.mockito.stubbing.Answer)
. -
Uses of Answer in org.mockito.stubbing
Subinterfaces of Answer in org.mockito.stubbingMethods in org.mockito.stubbing with parameters of type AnswerModifier and TypeMethodDescriptionUse it for stubbing consecutive calls inMockito.doAnswer(Answer)
style:Sets a generic Answer for the method.OngoingStubbing.thenAnswer
(Answer<?> answer) Sets a generic Answer for the method.