Package org.mockito.invocation
Interface InvocationFactory
public interface InvocationFactory
Available via
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...)
.
- Since:
- 2.10.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Behavior of the real method. -
Method Summary
Modifier and TypeMethodDescriptioncreateInvocation
(Object target, MockCreationSettings settings, Method method, InvocationFactory.RealMethodBehavior realMethod, Object... args) Creates instance of anInvocation
object.
-
Method Details
-
createInvocation
Invocation createInvocation(Object target, MockCreationSettings settings, Method method, InvocationFactory.RealMethodBehavior realMethod, Object... args) Creates instance of anInvocation
object. This method is useful for framework integrators to programmatically simulate method calls on mocks usingMockHandler
. It enables advanced framework integrations.- Parameters:
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- Returns:
- invocation instance
- Since:
- 2.14.0
-