且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring Boot 骆驼测试

更新时间:2022-01-08 01:06:50

尝试使用CamelSpringBootRunner.class作为运行器,并在测试中添加@SpringBootTest注解类.

Try to use the CamelSpringBootRunner.class as the runner and add the @SpringBootTest annotation to the test class.

示例来自 Camel 存储库

Example from the Camel repository

如果您将引导程序类更改为 SpringBootTestContextBootstrapper 那么它应该可以工作:

If you change your bootstrapper class to SpringBootTestContextBootstrapper then it should work:

@BootstrapWith(SpringBootTestContextBootstrapper.class)

您拥有的等效配置,但在这种情况下您不需要添加 ContextConfigurationBootstrapWith 注释:

@RunWith(CamelSpringBootRunner.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@MockEndpoints("log:*")
@DisableJmx(false)
@SpringBootTest(classes = MyClass.class)