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 (将#修改为@)