此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 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
测试类配置和@TestExecutionListeners
Java文档有关示例和更多详细信息。如果您发现需要切换
回到使用默认值TestExecutionListener
实现,请参阅注册TestExecutionListener
实现.