Interface TestExecutionListener
-
- All Known Implementing Classes:
LoggingListener
,SummaryGeneratingListener
@API(status=STABLE, since="1.0") public interface TestExecutionListener
Register an instance of this class with aLauncher
to be notified of events that occur during test execution.All methods in this class have empty default implementations. Concrete implementations may therefore override one or more of these methods to be notified of the selected events.
JUnit provides two example implementations:
Contrary to JUnit 4, test engines are supposed to report events not only for identifiers that represent executable leaves in the test plan but also for all intermediate containers. However, while both the JUnit Vintage and JUnit Jupiter engines comply with this contract, there is no way to guarantee this for third-party engines.
- Since:
- 1.0
- See Also:
Launcher
,TestPlan
,TestIdentifier
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default void
dynamicTestRegistered(TestIdentifier testIdentifier)
Called when a new, dynamicTestIdentifier
has been registered.default void
executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult)
Called when the execution of a leaf or subtree of theTestPlan
has finished, regardless of the outcome.default void
executionSkipped(TestIdentifier testIdentifier, java.lang.String reason)
Called when the execution of a leaf or subtree of theTestPlan
has been skipped.default void
executionStarted(TestIdentifier testIdentifier)
Called when the execution of a leaf or subtree of theTestPlan
is about to be started.default void
reportingEntryPublished(TestIdentifier testIdentifier, ReportEntry entry)
Called when additional test reporting data has been published for the suppliedTestIdentifier
.default void
testPlanExecutionFinished(TestPlan testPlan)
Called when the execution of theTestPlan
has finished, after all tests have been executed.default void
testPlanExecutionStarted(TestPlan testPlan)
Called when the execution of theTestPlan
has started, before any test has been executed.
-
-
-
Method Detail
-
testPlanExecutionStarted
default void testPlanExecutionStarted(TestPlan testPlan)
Called when the execution of theTestPlan
has started, before any test has been executed.- Parameters:
testPlan
- describes the tree of tests about to be executed
-
testPlanExecutionFinished
default void testPlanExecutionFinished(TestPlan testPlan)
Called when the execution of theTestPlan
has finished, after all tests have been executed.- Parameters:
testPlan
- describes the tree of tests that have been executed
-
dynamicTestRegistered
default void dynamicTestRegistered(TestIdentifier testIdentifier)
Called when a new, dynamicTestIdentifier
has been registered.A dynamic test is a test that is not known a-priori and therefore not contained in the original
TestPlan
.- Parameters:
testIdentifier
- the identifier of the newly registered test or container
-
executionSkipped
default void executionSkipped(TestIdentifier testIdentifier, java.lang.String reason)
Called when the execution of a leaf or subtree of theTestPlan
has been skipped.The
TestIdentifier
may represent a test or a container. In the case of a container, no listener methods will be called for any of its descendants.A skipped test or subtree of tests will never be reported as started or finished.
- Parameters:
testIdentifier
- the identifier of the skipped test or containerreason
- a human-readable message describing why the execution has been skipped
-
executionStarted
default void executionStarted(TestIdentifier testIdentifier)
Called when the execution of a leaf or subtree of theTestPlan
is about to be started.The
TestIdentifier
may represent a test or a container.This method will only be called if the test or container has not been skipped.
This method will be called for a container
TestIdentifier
before starting or skipping any of its children.- Parameters:
testIdentifier
- the identifier of the started test or container
-
executionFinished
default void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult)
Called when the execution of a leaf or subtree of theTestPlan
has finished, regardless of the outcome.The
TestIdentifier
may represent a test or a container.This method will only be called if the test or container has not been skipped.
This method will be called for a container
TestIdentifier
after all of its children have been skipped or have finished.The
TestExecutionResult
describes the result of the execution for the suppliedTestIdentifier
. The result does not include or aggregate the results of its children. For example, a container with a failing test will be reported asSUCCESSFUL
even if one or more of its children are reported asFAILED
.- Parameters:
testIdentifier
- the identifier of the finished test or containertestExecutionResult
- the (unaggregated) result of the execution for the suppliedTestIdentifier
- See Also:
TestExecutionResult
-
reportingEntryPublished
default void reportingEntryPublished(TestIdentifier testIdentifier, ReportEntry entry)
Called when additional test reporting data has been published for the suppliedTestIdentifier
.Can be called at any time during the execution of a test plan.
- Parameters:
testIdentifier
- describes the test or container to which the entry pertainsentry
- the publishedReportEntry
-
-