Sam Brannen opened SPR-15735 and commented
Status Quo
The test instance is not supplied to TestContextManager.beforeTestClass()
and TestContextManager.afterTestClass()
. Consequently, the beforeTestClass()
and afterTestClass()
methods of TestExecutionListener
implementations never have access to the test instance.
For JUnit 4, it is a moot point since the test instance is never available for class-level callbacks (due to per-method test instance lifecycle semantics). However, for TestNG the test instance is always available, and in JUnit Jupiter the test instance is available if the test class is annotated with @TestInstance(Lifecycle.PER_CLASS)
.
Deliverables
- Introduce overloaded variants of
TestContextManager.beforeTestClass()
andTestContextManager.afterTestClass()
that accept anObject testInstance
parameter and use it to update the state of the managedTestContext
. - Consider providing access to container-level exceptions as well (potentially in a separate issue).
Comment From: sbrannen
Closing due to lack of interest.