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.
semantics. If the test class is configured with
@TestInstance(Lifecycle.
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.
A symmetric TestInstancePreConstructCallback extension defines a callback
hook that is invoked prior to any test class instances being constructed.
Consult the documentation in Extension for details on constructor
requirements.
preDestroyTestInstance(ExtensionContext), TestInstancePostProcessor, TestInstancePreConstructCallback, TestInstanceFactory, ParameterResolver
| Modifier and Type | Method and Description |
|---|---|
| public void | preDestroyTestInstance(ExtensionContext
the current extension context; never context)nullCallback for processing test instances before they are destroyed. |
| public static void | preDestroyTestInstances(ExtensionContext
the current extension context; never context, Consumer<Object> nullthe callback to be invoked for every test instance of the
current extension context that is about to be destroyed; never
callback)nullUtility method for processing all test instances of an
|
| preDestroyTestInstance | back to summary |
|---|---|
| public void preDestroyTestInstance(ExtensionContext context) throws Exception Callback for processing test instances before they are destroyed. Contrary to
| |
| preDestroyTestInstances | back to summary |
|---|---|
| public static void preDestroyTestInstances(ExtensionContext context, Consumer<Object> callback) Utility method for processing all test instances of an
This method should be called in order to implement this interface correctly since it ensures that the right test instances are processed regardless of the used lifecycle. The supplied callback is called once per test instance that is about to be destroyed starting with the innermost one. This method is intended to be called from an implementation of
| |