@ContextCustomizerFactories
@ContextCustomizerFactories是一个注解,可以应用于测试类
注册ContextCustomizerFactory实现,则其
子类及其嵌套类。如果您希望在全球范围内注册工厂,您可以
应通过ContextCustomizerFactory配置.
以下示例显示了如何注册两个ContextCustomizerFactory实现:
-
Java
-
Kotlin
@ContextConfiguration
@ContextCustomizerFactories({CustomContextCustomizerFactory.class, AnotherContextCustomizerFactory.class}) (1)
class CustomContextCustomizerFactoryTests {
// class body...
}
| 1 | 注册 2ContextCustomizerFactory实现。 |
@ContextConfiguration
@ContextCustomizerFactories([CustomContextCustomizerFactory::class, AnotherContextCustomizerFactory::class]) (1)
class CustomContextCustomizerFactoryTests {
// class body...
}
| 1 | 注册 2ContextCustomizerFactory实现。 |
默认情况下,@ContextCustomizerFactories支持从
超类或封闭类。看@Nestedtest 类配置和@ContextCustomizerFactoriesJavadoc有关示例和更多详细信息。