Test Result Processing
TestWatcher defines the API for extensions that wish to process the results of test
method executions. Specifically, a TestWatcher will be invoked with contextual
information for the following events.
-
testDisabled: invoked after a disabled test method has been skipped -
testSuccessful: invoked after a test method has completed successfully -
testAborted: invoked after a test method has been aborted -
testFailed: invoked after a test method has failed
In contrast to the definition of "test method" presented in
Definitions, in this context test method refers to any @Test method
or @TestTemplate method (for example, a @RepeatedTest or @ParameterizedTest).
|
Extensions implementing this interface can be registered at the class level, instance
level, or method level. When registered at the class level, a TestWatcher will be
invoked for any contained test method including those in @Nested classes. When
registered at the method level, a TestWatcher will only be invoked for the test method
for which it was registered.
|
If a To ensure that a |
If there is a failure at the class level — for example, an exception thrown by a
@BeforeAll method — no test results will be reported. Similarly, if the test class is
disabled via an ExecutionCondition — for example, @Disabled — no test results will be
reported.
In contrast to other Extension APIs, a TestWatcher is not permitted to adversely
influence the execution of tests. Consequently, any exception thrown by a method in the
TestWatcher API will be logged at WARNING level and will not be allowed to propagate
or fail test execution.
|
Any instances of |