2013-08-20 70 views
2

我phantomjs和我詹金斯服务器上的工作casperjs接受的xUnit XML日志。 该测试已执行且成功。但这里的东西:詹金斯不是从casperjs

Casperjs记录其结果在log.xml文件。我想我可以在我的jenkins webUI上显示该xml文件的内容。我发现詹金斯是xUnit的插件,但预期它不工作:

[37; 42; 12次1mPASS在22.324s执行12通过测试,0失败,0 半信半疑,0跳过。 [0米

正如你可以看到测试是全成

[32; 1mResult日志存储在../../build/frontendtests/log.xml
[0米出版三叶草覆盖报告...出版四叶草XML 报告...出版三叶草覆盖效果...记录测试结果 [的xUnit] [INFO] - 在开始录制。 [的xUnit] [信息] - 处理 AUnit-3.X(默认)[的xUnit] [信息] - [AUnit-3.X(默认)] - 1个测试 报告文件(一个或多个)被发现与图案 '为测试框架 'AUnit-3.x(默认)'建立/ frontendtests/log.xml'相对于 '。 [xUnit] [错误] - 结果文件 '对于 度量标准'AUnit'无效。结果文件已被跳过。 [xUnit] [INFO] - 失败BUILD,因为'set build failed if error'选项被激活。

Jenkins构建失败,因为我的log.xml不支持AUnit。我也试过JUnit和JSUnit。同样的结果。但我不明白。 casperjs输出xunit xml文件,我安装了xunit插件。但该插件不读取我的log.xml。

你有什么解决办法吗?也许我的詹金斯设置是错误的?有任何想法吗?

谢谢...

这里是我的log.xml

<?xml version="1.0" encoding="UTF-8"?> <testsuites duration="3.859"> 
    <testsuite name="Checking the portal search for http://www.xxx.de/suche/jeans" tests="1" failures="0" errors="0" time="2.687" timestamp="2013-08-20T14:12:55.953Z" package="./execute_search_tests"> 
     <testcase name="Subject equals the expected value" classname="./execute_search_tests" time="2.687"></testcase> 
     <system-out></system-out> 
    </testsuite> 
    <testsuite name="Checking the portal search for http://www.xxx.de/suche/asjdfkshjkfhdsjkafhkjasd" tests="1" failures="0" errors="0" time="1.172" timestamp="2013-08-20T14:12:55.954Z" package="./execute_search_tests"> 
     <testcase name="Subject equals the expected value" classname="./execute_search_tests" time="1.172"></testcase> 
     <system-out></system-out> 
    </testsuite> </testsuites> 

回答

2

注意:您已配置了AUnit选择您的xUnit后生成作用。这是用于Ada单元测试。

但我还测试了的xUnit与JUnit的选项一起插件,它仍然失败。我甚至enabled more logs,但这并没有帮助。

Aug 21, 2013 12:00:05 AM com.thalesgroup.hudson.plugins.xunit.service.XUnitService errorSystemLogger 
SEVERE: [xUnit] - The result file '/Users/lacostej/.jenkins/workspace/test-casperjs-xunit/log.xml' for the metric 'JUnit' is not valid. The result file has been skipped. 
Aug 21, 2013 12:00:05 AM com.thalesgroup.hudson.plugins.xunit.service.XUnitService warningSystemLogger 
WARNING: [xUnit] - The file '/Users/lacostej/.jenkins/workspace/test-casperjs-xunit/log.xml' is an invalid file. 
Aug 21, 2013 12:00:05 AM com.thalesgroup.hudson.plugins.xunit.service.XUnitService infoSystemLogger 
INFO: [xUnit] - [JUnit] - 1 test report file(s) were found with the pattern 'log.xml' relative to '/Users/lacostej/.jenkins/workspace/test-casperjs-xunit' for the testing framework 'JUnit'. 

但是当我使用“JUnit测试结果报告”插件进行了一些测试并且解析进行的很好。

更新

当你发现了,问题是with the casperjs file using attribute duration instead of time for testsuites nodes。 Xunit比标准关于它更严格。

我的建议:

  1. 使用标准的JUnit解析,它的工作原理
  2. ,如果你真的想使用的xUnit,你必须把它固定,然后报告了xUnit的解析错误。这里是我使用的测试用例配置:https://gist.github.com/lacostej/6287937
  3. 或者可能尝试将自定义样式与XSL一起使用。您仍然需要调试并知道XML为什么不被接受。

我会选择选项#1或#2。

+0

谢谢,我选了#1。这很容易建立。这里有一个关于同一问题的另一个可能解决方案的链接:https://groups.google.com/forum/?hl=de#!topic/casperjs/n1tbi0K9Tnk(我没有尝试,但听起来很合理,但它可能有点肮脏的解决方案 –

+0

你是对的。 – coffeebreaks