注释类型 BeforeTestMethod
@Retention(RUNTIME) @Target({METHOD,ANNOTATION_TYPE}) @Documented @EventListener(BeforeTestMethodEvent.class) public @interface BeforeTestMethod
@EventListenerannotation used to consume aBeforeTestMethodEventpublished 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.beforeTestMethod(org.springframework.test.context.TestContext)lifecycle.Event processing can optionally be made conditional via a SpEL expression — for example,
@BeforeTestMethod("event.testContext.testMethod.name matches 'test.*'").The
EventPublishingTestExecutionListenermust be registered in order for this annotation to have an effect — for example, via@TestExecutionListeners.- 从以下版本开始:
- 5.2
- 作者:
- Frank Scheffler, Sam Brannen
- 另请参阅:
BeforeTestMethodEvent
可选元素概要
可选元素 修饰符和类型 可选元素 说明 StringvalueAlias forEventListener.condition().
元素详细资料
value
@AliasFor(annotation=EventListener.class, attribute="condition") String value
Alias forEventListener.condition().- 默认值:
- ""