@FunctionalInterface
@API(status=STABLE,
since="5.0")
public interface TestExecutionExceptionHandler
extends Extension
TestExecutionExceptionHandler defines the API for Extensions that wish to handle exceptions thrown during test execution.
In this context, test execution refers to the physical
invocation of a @Test method and not to any test-level extensions
or callbacks.
Common use cases include swallowing an exception if it's anticipated or rolling back a transaction in certain error scenarios.
Implementations must provide a no-args constructor.
| Modifier and Type | Method and Description |
|---|---|
void |
handleTestExecutionException(ExtensionContext context,
java.lang.Throwable throwable)
Handle the supplied
throwable. |
void handleTestExecutionException(ExtensionContext context, java.lang.Throwable throwable) throws java.lang.Throwable
throwable.
Implementors must perform one of the following.
throwable, thereby preventing propagation.throwable as is.throwable.If the supplied throwable is swallowed, subsequent
TestExecutionExceptionHandlers will not be invoked; otherwise,
the next registered TestExecutionExceptionHandler (if there is
one) will be invoked with any Throwable thrown by this handler.
Note that the execution
exception in the supplied ExtensionContext will not
contain the Throwable thrown during invocation of the corresponding
@Test method.
context - the current extension context; never nullthrowable - the Throwable to handle; never nulljava.lang.Throwable