@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 call InvocationInterceptor.Invocation.proceed()
or InvocationInterceptor.Invocation.skip()
exactly once on the supplied invocation. 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 and 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
Note that the test class may not have been initialized (static initialization) when this method is invoked.
T
- the result typeinvocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
null
Throwable
- 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
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
Throwable
- 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
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
Throwable
- 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
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
Throwable
- 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
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
null
Throwable
- 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
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
Throwable
- in case of failuresdefault void interceptDynamicTest(InvocationInterceptor.Invocation<Void> invocation, ExtensionContext extensionContext) throws Throwable
DynamicTest
.invocation
- the invocation that is being intercepted; never
null
extensionContext
- the current extension context; never null
Throwable
- 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
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
Throwable
- 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
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
Throwable
- in case of failuresCopyright © 2020. All rights reserved.