SonarQube 无法解析包含任何故障的 TEST-report.xml

2023-07-09移动开发问题
22

本文介绍了SonarQube 无法解析包含任何故障的 TEST-report.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

如何将 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 - 套件中失败的测试总数.失败是代码通过使用用于该目的的机制明确失败的测试.例如,通过 assertEquals
  • errors - 套件中出错的测试总数.一个错误的测试是一个没有预料到的问题.例如,未经检查的可投掷;或者测试实施有问题
  • skipped - 套件中忽略或跳过的测试总数
  • name - Full class name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documents
  • tests - The total number of tests in the suite
  • failures - 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 assertEquals
  • errors - 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 test
  • skipped - 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 报告解析器无法解析数字.您缺少两个参数:errorsskipped.我不知道您如何生成这些报告(哪个 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

从 Documents 目录存储和读取文件 iOS 5
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)...
2024-08-12 移动开发问题
9

如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?
How can i use MYSQL database connection in iphone application useing cocos2d?(如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?)...
2024-08-12 移动开发问题
5

在 cocos2d 中平滑拖动一个 Sprite - iPhone
Smoothly drag a Sprite in cocos2d - iPhone(在 cocos2d 中平滑拖动一个 Sprite - iPhone)...
2024-08-12 移动开发问题
10

没有cocos2D的xcode iphone粒子
xcode iphone particles without cocos2D(没有cocos2D的xcode iphone粒子)...
2024-08-12 移动开发问题
4

Cocos2d 人像模式在 iPhone 上不起作用
Cocos2d portrait mode not working on iPhone(Cocos2d 人像模式在 iPhone 上不起作用)...
2024-08-12 移动开发问题
2