TestInstancePreConstructCallback defines the API for Extensions that wish to be invoked prior to creation of test instances.
This extension is a symmetric counterpart to TestInstancePreDestroyCallback.
The use cases for this extension may include preparing context-sensitive arguments
that are injected into the instance's constructor.
Extensions that implement TestInstancePreConstructCallback 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,
TestInstancePreConstructCallback extensions may be registered at the
class level or at the method level. In the latter case, the extension will
only be applied to the test method for which it is registered.
Consult the documentation in Extension for details on constructor
requirements.
ExtensionContext ScopeAs of JUnit Jupiter 5.12, this API participates in the
TestInstantiationAwareExtension contract. Implementations of this API
may therefore choose to override
getTestInstantiationExtensionContextScope(ExtensionContext) to require a
test-method scoped ExtensionContext. See
preConstructTestInstance(TestInstanceFactoryContext, ExtensionContext)
for further details.
TestInstancePreDestroyCallback, TestInstanceFactory, ParameterResolver
| Modifier and Type | Method and Description |
|---|---|
| public void | preConstructTestInstance(TestInstanceFactoryContext
the context for the test instance about to be instantiated;
never factoryContext, ExtensionContext nullthe current extension context; never context)nullCallback invoked prior to test instances being constructed. |
| preConstructTestInstance | back to summary |
|---|---|
| public void preConstructTestInstance(TestInstanceFactoryContext factoryContext, ExtensionContext context) throws Exception Callback invoked prior to test instances being constructed. By default, the supplied
| |