|
对于最新的稳定版本,请使用 Spring Framework 6.2.10! |
@TestExecutionListeners
@TestExecutionListeners用于注册特定测试类的侦听器,其
子类及其嵌套类。如果您希望在全球范围内注册监听器,您可以
应通过中描述的自动发现机制进行注册TestExecutionListener配置.
以下示例演示如何注册两个TestExecutionListener实现:
-
Java
-
Kotlin
@ContextConfiguration
@TestExecutionListeners({CustomTestExecutionListener.class, AnotherTestExecutionListener.class}) (1)
class CustomTestExecutionListenerTests {
// class body...
}
| 1 | 寄存器二TestExecutionListener实现。 |
@ContextConfiguration
@TestExecutionListeners(CustomTestExecutionListener::class, AnotherTestExecutionListener::class) (1)
class CustomTestExecutionListenerTests {
// class body...
}
| 1 | 寄存器二TestExecutionListener实现。 |
默认情况下,@TestExecutionListeners支持继承
超类或封闭类。看@Nested测试类配置和@TestExecutionListenersJava文档有关示例和更多详细信息。如果您发现需要切换
回到使用默认值TestExecutionListener实现,请参阅注释
在注册TestExecutionListener实现.