Interface TestInstancePostProcessor

    • Method Detail

      • postProcessTestInstance

        void postProcessTestInstance​(java.lang.Object testInstance,
                                     ExtensionContext context)
                              throws java.lang.Exception
        Callback for post-processing the supplied test instance.

        By default, the supplied ExtensionContext represents the test class that's being post-processed. Extensions may override TestInstantiationAwareExtension.getTestInstantiationExtensionContextScope(org.junit.jupiter.api.extension.ExtensionContext) to return TEST_METHOD in order to change the scope of the ExtensionContext to the test method, unless the PER_CLASS lifecycle is used. Changing the scope makes test-specific data available to the implementation of this method and allows keeping state on the test level by using the provided Store instance.

        Note: the ExtensionContext supplied to a TestInstancePostProcessor will always return an empty Optional value from getTestInstance(). A TestInstancePostProcessor should therefore only attempt to process the supplied testInstance.

        Parameters:
        testInstance - the instance to post-process; never null
        context - the current extension context; never null
        Throws:
        java.lang.Exception