如何解决Camel Springboot 应用程序的测试用例需要更长的构建时间
我已经为我的 Spring Boot 应用程序编写了骆驼测试用例,如下所示。
@RunWith(Camelspringrunner.class)
@SpringBoottest
@ActiveProfiles("test")
@ContextConfiguration(classes = Application.class)
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
@UseAdviceWith
public class CamelTestClass {
@Autowired
private CamelContext camelContext;
private String routeID = "routeId";
Logger log = Logger.getLogger(String.valueOf(CamelSpringBootApplication.class));
@Test
@DirtiesContext
public void test1() throws Exception {
ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class);
RouteReifier.adviceWith(mcc.getRouteDeFinition(routeID),mcc,new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
doSOmething
}
});
mcc.start();
assertion
mcc.stop();
}
@Test
@DirtiesContext
public void test2() throws Exception {
ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class);
RouteReifier.adviceWith(mcc.getRouteDeFinition(routeID),new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
doSomething
}
});
mcc.start();
assertion
mcc.stop();
}
@Test
@DirtiesContext
public void test3() throws Exception {
ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class);
RouteReifier.adviceWith(mcc.getRouteDeFinition(routeID),new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
doSomething
}
});
mcc.start();
assertion
mcc.stop();
}
}
所以写了 3 个测试用例,在测试用例的每个开头我都必须启动骆驼上下文并在最后清除它。有了这个设置,在 maven 构建测试测试需要很长时间才能完成。大约有 30 个测试用例,构建需要 25 分钟才能完成。这里有测试用例在运行时间方面的优化空间吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。