Interface TestInstancePreConstructCallback

All Superinterfaces:
Extension
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface @API(status=STABLE, since="5.11") public interface TestInstancePreConstructCallback extends Extension
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.PER_CLASS) semantics. If the test class is configured with @TestInstance(Lifecycle.PER_METHOD) 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.

Constructor Requirements

Consult the documentation in Extension for details on constructor requirements.

Since:
5.9
See Also:
  • Method Details

    • preConstructTestInstance

      void preConstructTestInstance(TestInstanceFactoryContext factoryContext, ExtensionContext context) throws Exception
      Callback invoked prior to test instances being constructed.
      Parameters:
      factoryContext - the context for the test instance about to be instantiated; never null
      context - the current extension context; never null
      Throws:
      Exception