引导 TestContext 框架

Spring TestContext 框架内部的默认配置是 足以满足所有常见使用案例的需求。但是,有时开发团队或 第三方框架想要更改默认值ContextLoader,实现 习惯TestContextContextCache,则扩充默认的ContextCustomizerFactoryTestExecutionListenerimplementations 等。为 这种对 TestContext 框架运行方式的低级控制, Spring 提供了一个 引导策略。spring-doc.cadn.net.cn

TestContextBootstrapper定义用于引导 TestContext 框架的 SPI。一个TestContextBootstrapperTestContextManager加载TestExecutionListener实现,并构建TestContext它管理。您可以为 test 类(或 test class 层次结构)@BootstrapWith,直接或作为 meta-annotation 中。如果未使用@BootstrapWith,则DefaultTestContextBootstrapperWebTestContextBootstrapper,具体取决于是否存在@WebAppConfiguration.spring-doc.cadn.net.cn

由于TestContextBootstrapperSPI 将来可能会发生变化(以适应 new requirements),我们强烈建议实现者不要实现此接口 直接,而是扩展AbstractTestContextBootstrapper或它的混凝土之一 子类。spring-doc.cadn.net.cn


APP信息