Package org.mockito.invocation
Interface InvocationFactory
-
- All Known Implementing Classes:
DefaultInvocationFactory
@Incubating public interface InvocationFactory
Available viaMockitoFramework.getInvocationFactory()
. Provides means to create instances ofInvocation
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 ofInvocation
.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 ofInvocation
, usecreateInvocation(Object, MockCreationSettings, Method, RealMethodBehavior, Object...)
.- Since:
- 2.10.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
InvocationFactory.RealMethodBehavior<R>
Behavior of the real method.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description Invocation
createInvocation(java.lang.Object target, MockCreationSettings settings, java.lang.reflect.Method method, java.util.concurrent.Callable realMethod, java.lang.Object... args)
Deprecated.Invocation
createInvocation(java.lang.Object target, MockCreationSettings settings, java.lang.reflect.Method method, InvocationFactory.RealMethodBehavior realMethod, java.lang.Object... args)
Creates instance of anInvocation
object.
-
-
-
Method Detail
-
createInvocation
@Deprecated Invocation createInvocation(java.lang.Object target, MockCreationSettings settings, java.lang.reflect.Method method, java.util.concurrent.Callable realMethod, java.lang.Object... args)
Deprecated.UsecreateInvocation(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 ofInvocationFactory.RealMethodBehavior
. 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.10.0
-
createInvocation
@Incubating Invocation createInvocation(java.lang.Object target, MockCreationSettings settings, java.lang.reflect.Method method, InvocationFactory.RealMethodBehavior realMethod, java.lang.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
-
-