注释类型 PrepareTestInstance
@Retention(RUNTIME) @Target({METHOD,ANNOTATION_TYPE}) @Documented @EventListener(PrepareTestInstanceEvent.class) public @interface PrepareTestInstance
@EventListenerannotation used to consume aPrepareTestInstanceEventpublished by theEventPublishingTestExecutionListener.This annotation may be used on
@EventListener-compliant methods within a Spring testApplicationContext— for example, on methods in a@Configurationclass. A method annotated with this annotation will be invoked as part of theTestExecutionListener.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
EventPublishingTestExecutionListenermust be registered in order for this annotation to have an effect — for example, via@TestExecutionListeners.- 从以下版本开始:
- 5.2
- 作者:
- Frank Scheffler, Sam Brannen
- 另请参阅:
PrepareTestInstanceEvent
可选元素概要
可选元素 修饰符和类型 可选元素 说明 StringvalueAlias forEventListener.condition().
元素详细资料
value
@AliasFor(annotation=EventListener.class, attribute="condition") String value
Alias forEventListener.condition().- 默认值:
- ""