@Incubating public interface InvocationFactory
MockitoFramework.getInvocationFactory()
.
Provides means to create instances of Invocation
objects.
Useful for framework integrations that need to programmatically simulate method calls on mock objects.
To simulate a method call on mock, one needs an instance of Invocation
.
Please don't provide your own implementation of Invocation
type.
Mockito team needs flexibility to add new methods to this interface if we need to.
If you integrate Mockito framework and you need an instance of Invocation
, use createInvocation(Object, MockCreationSettings, Method, RealMethodBehavior, Object...)
.
Modifier and Type | Interface and Description |
---|---|
static interface |
InvocationFactory.RealMethodBehavior<R>
Behavior of the real method.
|
Modifier and Type | Method and Description |
---|---|
Invocation |
createInvocation(Object target,
MockCreationSettings settings,
Method method,
Callable realMethod,
Object... args)
Deprecated.
Use
createInvocation(Object, MockCreationSettings, Method, RealMethodBehavior, Object...) instead.
Why deprecated? We found use cases where we need to handle Throwable and ensure correct stack trace filtering
(removing Mockito internals from the stack trace). Hence the introduction of InvocationFactory.RealMethodBehavior .
Creates instance of an Invocation object.
This method is useful for framework integrators to programmatically simulate method calls on mocks using MockHandler .
It enables advanced framework integrations. |
Invocation |
createInvocation(Object target,
MockCreationSettings settings,
Method method,
InvocationFactory.RealMethodBehavior realMethod,
Object... args)
Creates instance of an
Invocation object. |
@Deprecated Invocation createInvocation(Object target, MockCreationSettings settings, Method method, Callable realMethod, Object... args)
createInvocation(Object, MockCreationSettings, Method, RealMethodBehavior, Object...)
instead.
Why deprecated? We found use cases where we need to handle Throwable and ensure correct stack trace filtering
(removing Mockito internals from the stack trace). Hence the introduction of InvocationFactory.RealMethodBehavior
.
Creates instance of an Invocation
object.
This method is useful for framework integrators to programmatically simulate method calls on mocks using MockHandler
.
It enables advanced framework integrations.target
- the mock object the method is invoked on.settings
- creation settings of the mock object.method
- java method invoked on mock.realMethod
- real method behavior. Needed for spying / invoking real behavior on mock objects.args
- the java method arguments@Incubating Invocation createInvocation(Object target, MockCreationSettings settings, Method method, InvocationFactory.RealMethodBehavior realMethod, Object... args)
Invocation
object.
This method is useful for framework integrators to programmatically simulate method calls on mocks using MockHandler
.
It enables advanced framework integrations.target
- the mock object the method is invoked on.settings
- creation settings of the mock object.method
- java method invoked on mock.realMethod
- real method behavior. Needed for spying / invoking real behavior on mock objects.args
- the java method arguments