@FunctionalInterface @API(status=EXPERIMENTAL, since="5.6") public interface TestInstancePreDestroyCallback extends Extension
TestInstancePreDestroyCallback
defines the API for Extensions
that wish to process test instances after they have been
used in tests but before they are destroyed.
Common use cases include releasing resources that have been created for the test instance, invoking custom clean-up methods on the test instance, etc.
Extensions that implement TestInstancePreDestroyCallback
must be
registered at the class level if the test class is configured with
@TestInstance(Lifecycle.PER_CLASS)
semantics. If the test class is configured with
@TestInstance(Lifecycle.PER_METHOD)
semantics, TestInstancePreDestroyCallback
extensions may be registered
at the class level or at the method level. In the latter case, the
TestInstancePreDestroyCallback
extension will only be applied to the
test method for which it is registered.
Consult the documentation in Extension
for details on constructor
requirements.
preDestroyTestInstance(ExtensionContext)
,
TestInstancePostProcessor
,
TestInstanceFactory
,
ParameterResolver
Modifier and Type | Method and Description |
---|---|
void |
preDestroyTestInstance(ExtensionContext context)
Callback for processing a test instance before it is destroyed.
|
void preDestroyTestInstance(ExtensionContext context) throws java.lang.Exception
context
- the current extension context; never null
java.lang.Exception
ExtensionContext.getTestInstance()
,
ExtensionContext.getRequiredTestInstance()