InvocationInterceptor defines the API for Extensions that wish to intercept calls to test code.
Each method in this class must call Invocation#proceed() or Invocation#skip() exactly once on the supplied invocation. Otherwise, the
enclosing test or container will be reported as failed.
The default implementation calls proceed() on the supplied invocation.
Consult the documentation in Extension for details on
constructor requirements.
ExtensionContext ScopeAs of JUnit Jupiter 5.12, this API participates in the
TestInstantiationAwareExtension contract. Implementations of this API
may therefore choose to override
getTestInstantiationExtensionContextScope(ExtensionContext). See
interceptTestClassConstructor(Invocation, ReflectiveInvocationContext, ExtensionContext)
for details.
Invocation, ReflectiveInvocationContext, ExtensionContext
| Modifier and Type | Class and Description |
|---|---|
| public static interface | InvocationInterceptor.
the result type T extends @Nullable Object>An invocation that returns a result and may throw a |
| Modifier and Type | Method and Description |
|---|---|
| public default void | interceptAfterAllMethod(InvocationInterceptor.
the invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of an |
| public default void | interceptAfterEachMethod(InvocationInterceptor.
the invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of an |
| public default void | interceptBeforeAllMethod(InvocationInterceptor.
the invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of a |
| public default void | interceptBeforeEachMethod(InvocationInterceptor.
the invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of a |
| public default void | interceptDynamicTest(InvocationInterceptor.
the invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of a |
| public default < the result type T> T | Returns: the result of the invocation; nevernullthe invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of a test class constructor. |
| public default < the result type T extends @Nullable Object> T | Returns: the result of the invocation; potentiallynullthe invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of a |
| public default void | interceptTestMethod(InvocationInterceptor.
the invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of a |
| public default void | interceptTestTemplateMethod(InvocationInterceptor.
the invocation that is being intercepted; never
invocation,nullthe context of the invocation that is being
intercepted; never invocationContext, ExtensionContext nullthe current extension context; never extensionContext)nullIntercept the invocation of a |
| interceptAfterAllMethod | back to summary |
|---|---|
| public default void interceptAfterAllMethod(InvocationInterceptor. Intercept the invocation of an
| |
| interceptAfterEachMethod | back to summary |
|---|---|
| public default void interceptAfterEachMethod(InvocationInterceptor. Intercept the invocation of an
| |
| interceptBeforeAllMethod | back to summary |
|---|---|
| public default void interceptBeforeAllMethod(InvocationInterceptor. Intercept the invocation of a
| |
| interceptBeforeEachMethod | back to summary |
|---|---|
| public default void interceptBeforeEachMethod(InvocationInterceptor. Intercept the invocation of a
| |
| interceptDynamicTest | back to summary |
|---|---|
| public default void interceptDynamicTest(InvocationInterceptor. Intercept the invocation of a
| |
| interceptTestClassConstructor | back to summary |
|---|---|
| public default <T> T interceptTestClassConstructor(InvocationInterceptor. Intercept the invocation of a test class constructor. Note that the test class may not have been initialized (static initialization) when this method is invoked. By default, the supplied
| |
| interceptTestFactoryMethod | back to summary |
|---|---|
| public default <T extends @Nullable Object> T interceptTestFactoryMethod(InvocationInterceptor. Intercept the invocation of a
| |
| interceptTestMethod | back to summary |
|---|---|
| public default void interceptTestMethod(InvocationInterceptor. Intercept the invocation of a
| |
| interceptTestTemplateMethod | back to summary |
|---|---|
| public default void interceptTestTemplateMethod(InvocationInterceptor. Intercept the invocation of a
| |
Throwable.
This interface is not intended to be implemented by clients.
| Modifier and Type | Method and Description |
|---|---|
| public T | |
| public default void |
| proceed | back to summary |
|---|---|
| public T proceed() throws Throwable Proceed with this invocation.
| |
| skip | back to summary |
|---|---|
| public default void skip() Explicitly skip this invocation. This allows to bypass the check that | |