我的 phantomjs 和 casperjs 在我的 jenkins 服务器上运行。 测试已执行并成功。但事情是这样的:
Casperjs 将其结果记录在 log.xml 文件中。我想我可以在我的 jenkins webUI 上显示该 xml 文件的内容。我找到了 jenkins 的 xunit 插件,但它没有按预期工作:
[37;42;1mPASS 12 tests executed in 22.324s, 12 passed, 0 failed, 0 dubious, 0 skipped. [0m
可以看到测试成功
[32;1mResult log stored in ../../build/frontendtests/log.xml
[0m Publishing Clover coverage report... Publishing Clover XML report... Publishing Clover coverage results... Recording test results [xUnit] [INFO] - Starting to record. [xUnit] [INFO] - Processing AUnit-3.x (default) [xUnit] [INFO] - [AUnit-3.x (default)] - 1 test report file(s) were found with the pattern 'build/frontendtests/log.xml' relative to ' for the testing framework 'AUnit-3.x (default)'. [xUnit] [ERROR] - The result file ' for the metric 'AUnit' is not valid. The result file has been skipped. [xUnit] [INFO] - Fail BUILD because 'set build failed if errors' option is activated.
Jenkins 构建失败,因为我的 log.xml 不适用于 AUnit。我还尝试了 JUnit 和 JSUnit。相同的结果。但我不明白。 casperjs 导出 xunit xml 文件,我安装了 xunit 插件。但该插件不读取我的 log.xml。
你有什么解决办法吗?也许我的 Jenkins 设置是错误的?有什么想法吗?
谢谢...
这是我的 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>
最佳答案
注意:您已使用 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 比标准 junit 更严格。
我的建议:
- 使用标准的 JUnit 解析,它可以工作
- 如果你真的想使用 xunit,你必须修复它,然后报告 xunit 解析的错误。这是我使用的测试用例配置:https://gist.github.com/lacostej/6287937
- 或者尝试将自定义样式与 XSL 一起使用。您仍然需要调试并了解为什么您的 XML 不被接受。
我会选择选项 #1 或 #2。
关于javascript - jenkins 不接受来自 casperjs 的 xunit xml 日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18337233/