|
对于最新的稳定版本,请使用 Spring Framework 7.0.6! |
@ContextCustomizerFactories
@ContextCustomizerFactories 用于为特定的测试类、其子类和嵌套类注册 ContextCustomizerFactory 实现。如果
希望全局注册一个工厂,则应通过
ContextCustomizerFactory 配置中描述的自动发现机制进行注册。
以下示例展示了如何注册两个ContextCustomizerFactory实现:
-
Java
-
Kotlin
@ContextConfiguration
@ContextCustomizerFactories({CustomContextCustomizerFactory.class, AnotherContextCustomizerFactory.class}) (1)
class CustomContextCustomizerFactoryTests {
// class body...
}
| 1 | 注册两个ContextCustomizerFactory实现。 |
@ContextConfiguration
@ContextCustomizerFactories([CustomContextCustomizerFactory::class, AnotherContextCustomizerFactory::class]) (1)
class CustomContextCustomizerFactoryTests {
// class body...
}
| 1 | 注册两个ContextCustomizerFactory实现。 |
默认情况下,@ContextCustomizerFactories 提供了从超类或外部类继承工厂的支持。请参阅
@Nested 测试类配置 和
@ContextCustomizerFactories
javadoc 中的示例及更多详细信息。