Interface TestWatcher
-
- All Superinterfaces:
Extension
@API(status=EXPERIMENTAL, since="5.4") public interface TestWatcher extends ExtensionTestWatcherdefines the API forExtensionsthat wish to process test results.The methods in this API are called after a test has been skipped or executed. Any
CloseableResourceobjects stored in theStoreof the suppliedExtensionContextwill have already been closed before methods in this API are invoked.Please note that this API is currently only used to report the results of
@Testmethods and@TestTemplatemethods (e.g.,@RepeatedTestand@ParameterizedTest). Moreover, if there is a failure at the class level — for example, an exception thrown by a@BeforeAllmethod — no test results will be reported.Extensions implementing this API can be registered at any level.
Exception Handling
In contrast to other
ExtensionAPIs, aTestWatcheris not permitted to adversely influence the execution of tests. Consequently, any exception thrown by a method in theTestWatcherAPI will be logged atWARNINGlevel and will not be allowed to propagate or fail test execution.- Since:
- 5.4
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidtestAborted(ExtensionContext context, java.lang.Throwable cause)Invoked after a test has been aborted.voidtestDisabled(ExtensionContext context, java.util.Optional<java.lang.String> reason)Invoked after a disabled test has been skipped.voidtestFailed(ExtensionContext context, java.lang.Throwable cause)Invoked after a test has failed.voidtestSuccessful(ExtensionContext context)Invoked after a test has completed successfully.
-
-
-
Method Detail
-
testDisabled
void testDisabled(ExtensionContext context, java.util.Optional<java.lang.String> reason)
Invoked after a disabled test has been skipped.- Parameters:
context- the current extension context; nevernullreason- the reason the test is disabled; nevernull
-
testSuccessful
void testSuccessful(ExtensionContext context)
Invoked after a test has completed successfully.- Parameters:
context- the current extension context; nevernull
-
testAborted
void testAborted(ExtensionContext context, java.lang.Throwable cause)
Invoked after a test has been aborted.- Parameters:
context- the current extension context; nevernullcause- the throwable responsible for the test being aborted; may benull
-
testFailed
void testFailed(ExtensionContext context, java.lang.Throwable cause)
Invoked after a test has failed.- Parameters:
context- the current extension context; nevernullcause- the throwable that caused test failure; may benull
-
-