Unit testing ApacheCamel:如何在使用CamelTestSupport进行单元测试时打印异常跟踪

Unit testing ApacheCamel:如何在使用CamelTestSupport进行单元测试时打印异常跟踪,unit-testing,exception-handling,apache-camel,integration,testng,Unit Testing,Exception Handling,Apache Camel,Integration,Testng,使用Camel core v2.14.1和Camel testng v2.14.1 正在尝试对基本路由进行单元测试 RouteBuilder类命名为FileToJmsRB,路由是这样配置的 @Override public void configure() { from("file:C:\\camel_folder\\orders") .when(fileToJmsConditions.camelFileNameEndingWithXml(this))

使用Camel core v2.14.1和Camel testng v2.14.1

正在尝试对基本路由进行单元测试

RouteBuilder类命名为FileToJmsRB,路由是这样配置的

@Override
public void configure() {
     from("file:C:\\camel_folder\\orders")
       .when(fileToJmsConditions.camelFileNameEndingWithXml(this))
            .to("file:C:\\camel_folder\\recieved")
}
fileToJmsConditions是一个变量,我无法将其作为Springbean注入

我的测试类扩展了CamelTestSupport,它覆盖createRouteBuilder,如下所示

@Override
protected RouteBuilder createRouteBuilder() throws Exception{
    return new FileToJmsRB();
}
我将一个方法配置为test

@Test
public void testTextFileMove() throws Exception{
    template.sendBodyAndHeader("file:C:\\camel_folder\\orders"
        , "Hello World"
        , Exchange.FILE_NAME
        , "hello.txt");

    Thread.sleep(10000);

    File target = new File("C:\\camel_folder\\recieved\\hello.txt");
    assertTrue(target.exists(), "File Not Moved");
}
跑步时

maven install
在该项目中,我希望控制台中出现带有StackTrace的空指针异常

但是,没有抛出异常类型的提示,也没有打印stacktrace。它只是说测试失败了,但没有打印异常或堆栈跟踪的类型

 Tests run: 2, Failures: 1, Errors: 0, Skipped: 1
但是,如果我在FileToJmsRB类中使用 尝试接住 只有这样,我才能看到抛出NullPointerException并打印堆栈跟踪


没有其他更优雅的方式来处理这个问题吗?因为这样我必须试着…抓住。。。在每个Route Builder类中?

是的,我们可以改进camel test/camel testng,以便更好地从Route Builder报告运行时异常。欢迎您在Apache Camel上登录票证。您可以共享我可以在其中登录Apache Camel票证的URL吗?您可以在此处找到问题追踪器的链接:@ClausIbsen谢谢。创建了票据@ClausIbsen你知道为什么测试运行统计数据说当我只编写了一个测试方法时,有两个测试运行吗?