问题描述
如何将 XML 报告发送到 SonarQube?我的意思是,虽然 TEST-report.xml 文件包含任何失败,但导入操作会失败.我收到一个错误:
How to send the XML report to SonarQube? I mean, while the TEST-report.xml file contains any failures, the import operation fails. I got an error:
Running SonarQube using SonarQube Runner.17:18:18.452 ERROR: Error during SonarScanner execution
java.lang.NullPointerException
at java.text.DecimalFormat.parse(DecimalFormat.java:2030)
at java.text.NumberFormat.parse(NumberFormat.java:383)
...
TEST-report.xml 文件 (JUnit) 包含如下内容:
The TEST-report.xml file (JUnit) contains something like:
<?xml version='1.0' encoding='UTF-8'?>
<testsuites name='X UITests.xctest' tests='12' failures='3'>
<testsuite name='X.MoreViewTests' tests='1' failures='1'>
<testcase classname='X.MoreViewTests' name='testSucceed_allAction'>
<failure message='XCTAssertTrue failed'>X UITests/Cases/Bottom Navigation/MoreViewTests.swift:212</failure>
</testcase>
</testsuite>
<testsuite name='X.OrderViewTests' tests='1' failures='0'>
<testcase classname='X.OrderViewTests' name='testSucceed_allAction' time='68.570'/>
</testsuite>
</testsuites>
但是当我删除失败行时,变成:
But when I removed the failure lines, becomes:
<?xml version='1.0' encoding='UTF-8'?>
<testsuites name='X UITests.xctest' tests='12' failures='3'>
<testsuite name='X.OrderViewTests' tests='1' failures='0'>
<testcase classname='X.OrderViewTests' name='testSucceed_allAction' time='68.570'/>
</testsuite>
</testsuites>
它有效.任何的想法?谢谢.
It works. Any idea? Thanks.
推荐答案
您的 XML 报告无效(不符合 Surefire XML 格式要求).
Your XML report is invalid (doesn't meet the Surefire XML format requirements).
testsuite所需参数:
name- 非聚合测试套件文档的测试的完整类名.没有用于聚合测试套件文档的包的类名tests- 套件中的测试总数failures- 套件中失败的测试总数.失败是代码通过使用用于该目的的机制明确失败的测试.例如,通过 assertEqualserrors- 套件中出错的测试总数.一个错误的测试是一个没有预料到的问题.例如,未经检查的可投掷;或者测试实施有问题skipped- 套件中忽略或跳过的测试总数
name- Full class name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documentstests- The total number of tests in the suitefailures- The total number of tests in the suite that failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEqualserrors- The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the testskipped- The total number of ignored or skipped tests in the suite
异常以DecimalFormat.parse
java.lang.NullPointerException
at java.text.DecimalFormat.parse(DecimalFormat.java:2030)
at java.text.NumberFormat.parse(NumberFormat.java:383)
这意味着 XML 报告解析器无法解析数字.您缺少两个参数:errors 和 skipped.我不知道您如何生成这些报告(哪个 JUnit 版本等),但可能使用的工具已过时或配置错误.
which means that the XML report parser couldn't parse a number. You have two missing parameters: errors and skipped. I don't know how you generate these reports (which JUnit version etc.), but probably the used tool is outdated or miss-configured.
这篇关于SonarQube 无法解析包含任何故障的 TEST-report.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)