Annotation Interface PrepareTestInstance
@EventListener
annotation used to consume a
PrepareTestInstanceEvent
published by the
EventPublishingTestExecutionListener
.
This annotation may be used on @EventListener
-compliant methods within
a Spring test ApplicationContext
— for example, on methods in a
@Configuration
class. A method annotated with this annotation will be invoked as part of the
TestExecutionListener.prepareTestInstance(org.springframework.test.context.TestContext)
lifecycle.
Event processing can optionally be made conditional via
a SpEL expression — for example,
@PrepareTestInstance("event.testContext.testClass.name matches '.+IntegrationTests'")
.
The EventPublishingTestExecutionListener
must be registered in order
for this annotation to have an effect — for example, via
@TestExecutionListeners
.
Note, however, that the EventPublishingTestExecutionListener
is registered
by default.
- Since:
- 5.2
- Author:
- Frank Scheffler, Sam Brannen
- See Also:
-
Optional Element Summary
-
Element Details
-
value
Alias forEventListener.condition()
.- Default:
- ""
-