LifecycleMethodExecutionExceptionHandler defines the API for
Extensions that wish to handle exceptions thrown during
the execution of @BeforeAll, @BeforeEach, @AfterEach,
and @AfterAll lifecycle methods.
Common use cases include swallowing an exception if it's anticipated, logging errors, or rolling back a transaction in certain error scenarios.
Implementations of this extension API must be registered at the class level
if exceptions thrown from @BeforeAll or @AfterAll methods are
to be handled. When registered at the test level, only exceptions thrown from
@BeforeEach or @AfterEach methods will be handled.
Consult the documentation in Extension for details on constructor
requirements.
An implementation of an exception handler method defined in this API must perform one of the following.
Throwable as is, which is the default implementation.Throwable, thereby preventing propagation.Throwable.If the supplied Throwable is swallowed by a handler method, subsequent
handler methods for the same lifecycle will not be invoked; otherwise, the
corresponding handler method of the next registered
LifecycleMethodExecutionExceptionHandler (if there is one) will be
invoked with any Throwable thrown by the previous handler.
TestExecutionExceptionHandler
| Modifier and Type | Method and Description |
|---|---|
| public default void | handleAfterAllMethodExecutionException(ExtensionContext
the current extension context; never context, Throwable nullthe throwable)Throwable to handle; never nullHandle the supplied |
| public default void | handleAfterEachMethodExecutionException(ExtensionContext
the current extension context; never context, Throwable nullthe throwable)Throwable to handle; never nullHandle the supplied |
| public default void | handleBeforeAllMethodExecutionException(ExtensionContext
the current extension context; never context, Throwable nullthe throwable)Throwable to handle; never nullHandle the supplied |
| public default void | handleBeforeEachMethodExecutionException(ExtensionContext
the current extension context; never context, Throwable nullthe throwable)Throwable to handle; never nullHandle the supplied |
| handleAfterAllMethodExecutionException | back to summary |
|---|---|
| public default void handleAfterAllMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable Handle the supplied Please refer to the class-level Javadoc for Implementation Guidelines.
| |
| handleAfterEachMethodExecutionException | back to summary |
|---|---|
| public default void handleAfterEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable Handle the supplied Please refer to the class-level Javadoc for Implementation Guidelines.
| |
| handleBeforeAllMethodExecutionException | back to summary |
|---|---|
| public default void handleBeforeAllMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable Handle the supplied Please refer to the class-level Javadoc for Implementation Guidelines.
| |
| handleBeforeEachMethodExecutionException | back to summary |
|---|---|
| public default void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable Handle the supplied Please refer to the class-level Javadoc for Implementation Guidelines.
| |