Package org.junit.jupiter.api.extension
Interface TestInstancePostProcessor
-
- 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.0") public interface TestInstancePostProcessor extends Extension
TestInstancePostProcessor
defines the API forExtensions
that wish to post-process test instances.Common use cases include injecting dependencies into the test instance, invoking custom initialization methods on the test instance, etc.
Extensions that implement
TestInstancePostProcessor
must be registered at the class level.Constructor Requirements
Consult the documentation in
Extension
for details on constructor requirements.- Since:
- 5.0
- See Also:
postProcessTestInstance(Object, ExtensionContext)
,TestInstanceFactory
,ParameterResolver
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
postProcessTestInstance(Object testInstance, ExtensionContext context)
Callback for post-processing the supplied test instance.
-
-
-
Method Detail
-
postProcessTestInstance
void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception
Callback for post-processing the supplied test instance.Note: the
ExtensionContext
supplied to aTestInstancePostProcessor
will always return an emptyOptional
value fromgetTestInstance()
. ATestInstancePostProcessor
should therefore only attempt to process the suppliedtestInstance
.- Parameters:
testInstance
- the instance to post-process; nevernull
context
- the current extension context; nevernull
- Throws:
Exception
-
-