Extension@API(status=EXPERIMENTAL,
since="5.5")
public interface InvocationInterceptor
extends Extension
InvocationInterceptor defines the API for Extensions that wish to intercept calls to test code.
Each method in this class must execute the supplied invocation exactly once. Otherwise, the enclosing test or container will be reported as failed.
The default implementation simply calls proceed() on the supplied invocation.
Consult the documentation in Extension for details on
constructor requirements.
InvocationInterceptor.Invocation,
ReflectiveInvocationContext,
ExtensionContext| Modifier and Type | Interface | Description |
|---|---|---|
static interface |
InvocationInterceptor.Invocation<T> |
An invocation that returns a result and may throw a
Throwable. |
default <T> T interceptTestClassConstructor(InvocationInterceptor.Invocation<T> invocation, ReflectiveInvocationContext<Constructor<T>> invocationContext, ExtensionContext extensionContext) throws Throwable
T - the result typeinvocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullnullThrowable - in case of failuredefault void interceptBeforeAllMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable
@BeforeAll method.invocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullThrowable - in case of failuresdefault void interceptBeforeEachMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable
@BeforeEach method.invocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullThrowable - in case of failuresdefault void interceptTestMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable
@Test method.invocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullThrowable - in case of failuresdefault <T> T interceptTestFactoryMethod(InvocationInterceptor.Invocation<T> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable
@TestFactory method.T - the result typeinvocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullnullThrowable - in case of failuresdefault void interceptTestTemplateMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable
@TestTemplate method.invocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullThrowable - in case of failuresdefault void interceptDynamicTest(InvocationInterceptor.Invocation<Void> invocation, ExtensionContext extensionContext) throws Throwable
DynamicTest.invocation - the invocation that is being intercepted; never
nullextensionContext - the current extension context; never nullThrowable - in case of failuresdefault void interceptAfterEachMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable
@AfterEach method.invocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullThrowable - in case of failuresdefault void interceptAfterAllMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable
@AfterAll method.invocation - the invocation that is being intercepted; never
nullinvocationContext - the context of the invocation that is being
intercepted; never nullextensionContext - the current extension context; never nullThrowable - in case of failuresCopyright © 2019. All rights reserved.