AfterEachCallback
, Extension
, TestExecutionExceptionHandler
@API(status=EXPERIMENTAL, since="5.0") public class ExpectedExceptionSupport extends java.lang.Object implements AfterEachCallback, TestExecutionExceptionHandler
Extension
provides native support for the
ExpectedException
rule from JUnit 4.
By using this class-level extension on a test class,
ExpectedException
can continue to be used.
However, you should rather switch to
Assertions.assertThrows(java.lang.Class<T>, org.junit.jupiter.api.function.Executable)
for new code.
Assertions.assertThrows(java.lang.Class<T>, org.junit.jupiter.api.function.Executable)
,
ExpectedException
,
TestRule
,
Rule
Constructor | Description |
---|---|
ExpectedExceptionSupport() |
Modifier and Type | Method | Description |
---|---|---|
void |
afterEach(ExtensionContext context) |
Callback that is invoked after each test has been invoked.
|
void |
handleTestExecutionException(ExtensionContext context,
java.lang.Throwable throwable) |
Handle the supplied
throwable . |
public void handleTestExecutionException(ExtensionContext context, java.lang.Throwable throwable) throws java.lang.Throwable
TestExecutionExceptionHandler
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.
handleTestExecutionException
in interface TestExecutionExceptionHandler
context
- the current extension context; never null
throwable
- the Throwable
to handle; never null
java.lang.Throwable
public void afterEach(ExtensionContext context) throws java.lang.Exception
AfterEachCallback
afterEach
in interface AfterEachCallback
context
- the current extension context; never null
java.lang.Exception