当前位置: 首页 > 知识库问答 >
问题:

在声纳上发布JUnit测试报告

宫亦
2023-03-14

我有Maven Java项目的JUnit XML报告,而不是源文件。我希望Sonarqube 4.5.7通过执行以下命令来发布这些报告:“mvn sonar:sonar”。

Sonarqube安装在远程服务器上,安装了java-plugin-3.8和其他插件。

我所有的JUnitXML报告都在一个名为“reports”的目录中。

pom。项目根目录上的xml如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>***</groupId>
  <artifactId>***</artifactId>
  <version>1.0.0</version>
  <packaging>pom</packaging>
  <name>MEDIATION-DEV1_SMED-Apporteur</name>
  <properties>
    <sonar.junit.reportsPath>reports</sonar.junit.reportsPath>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.jdbc.username>***</sonar.jdbc.username>
    <sonar.jdbc.password>***</sonar.jdbc.password>
    <sonar.jdbc.url>jdbc:mysql://***useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url>
    <sonar.language>java</sonar.language>
    <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
    <sonar.jdbc.dialect>mysql</sonar.jdbc.dialect>
    <sonar.host.url>***</sonar.host.url>   
  </properties>
</project>

当我执行“mvn声纳:声纳”时,我得到:

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ***
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Apporteur ---
[INFO] Deleting E:\jenkins-slave\workspace\workspace\Mediation-Sonar-Test-Alex\target
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ***
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.0.2:sonar (default-cli) @ Apporteur ---
[INFO] User cache: C:\Users\S046499\.sonar\cache
[INFO] SonarQube version: 4.5.7
[INFO] Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
[INFO] [14:01:41.624] Load global referentials...
[INFO] [14:01:41.861] Load global referentials done: 241 ms
[INFO] [14:01:41.888] User cache: C:\Users\S046499\.sonar\cache
[INFO] [14:01:41.904] Install plugins
[INFO] [14:01:42.141] Install JDBC driver
[INFO] [14:01:42.161] Create JDBC datasource for jdbc:*** useUnicode=true&characterEncoding=utf8
[INFO] [14:01:43.969] Initializing Hibernate
[INFO] [14:01:47.254] views plugin licensed to ***, EVALUATION [Expiration: 2016-06-17, Server: *]
[INFO] [14:01:47.560] Load project referentials...
[INFO] [14:01:48.253] Load project referentials done: 693 ms
[INFO] [14:01:48.255] Load project settings
[INFO] [14:01:48.837] Loading technical debt model...
[INFO] [14:01:48.889] Loading technical debt model done: 52 ms
[INFO] [14:01:48.895] Apply project exclusions
[WARN] [14:01:49.305] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[INFO] [14:01:49.408] -------------  Scan ***
[INFO] [14:01:49.421] Load module settings
[INFO] [14:01:51.137] Language is forced to java
[INFO] [14:01:51.144] Loading rules...
[INFO] [14:01:52.704] Loading rules done: 1560 ms
[INFO] [14:01:52.749] Configure Maven plugins
[INFO] [14:01:53.031] Compare to previous analysis (2016-06-09)
[INFO] [14:01:53.053] Compare over 30 days (2016-05-10, analysis of 2016-06-01 14:22:45.0)
[INFO] [14:01:53.057] No quality gate is configured.
[INFO] [14:01:54.287] Base dir: E:\jenkins-slave\workspace\workspace\Mediation-Sonar-Test-Alex
[INFO] [14:01:54.288] Working dir: E:\jenkins-slave\workspace\workspace\Mediation-Sonar-Test-Alex\target\sonar
[INFO] [14:01:54.292] Source paths: pom.xml
[INFO] [14:01:54.308] Source encoding: windows-1252, default locale: en_US
[INFO] [14:01:54.309] Index files
[INFO] [14:01:54.366] 0 files indexed
[INFO] [14:01:54.368] Quality profile for java: Sonar way
[INFO] [14:01:54.416] Sensor QProfileSensor...
[INFO] [14:01:54.446] Sensor QProfileSensor done: 30 ms
[INFO] [14:01:54.447] Sensor InitialOpenIssuesSensor...
[INFO] [14:01:54.623] Sensor InitialOpenIssuesSensor done: 176 ms
[INFO] [14:01:54.624] Sensor ProjectLinksSensor...
[INFO] [14:01:54.677] Sensor ProjectLinksSensor done: 53 ms
[INFO] [14:01:54.682] Sensor VersionEventsSensor...
[INFO] [14:01:54.733] Sensor VersionEventsSensor done: 51 ms
[INFO] [14:01:54.734] Sensor FileHashSensor...
[INFO] [14:01:54.735] Sensor FileHashSensor done: 1 ms
[INFO] [14:01:54.735] Sensor Maven dependencies...
[INFO] [14:01:55.009] Sensor Maven dependencies done: 273 ms
[INFO] [14:01:55.013] Sensor CPD Sensor (wrapped)...
[INFO] [14:01:55.017] JavaCpdEngine is used for java
[INFO] [14:01:55.018] Sensor CPD Sensor (wrapped) done: 6 ms
[INFO] [14:01:55.464] Execute decorators...
[INFO] [14:01:55.955] Store results in database
[INFO] [14:01:56.238] ANALYSIS SUCCESSFUL, you can browse ***
[INFO] [14:01:56.329] Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
[INFO] [14:01:56.348] -> Keep one snapshot per day between 2016-05-12 and 2016-06-08
[INFO] [14:01:56.354] -> Keep one snapshot per week between 2015-06-11 and 2016-05-12
[INFO] [14:01:56.358] -> Keep one snapshot per month between 2011-06-16 and 2015-06-11
[INFO] [14:01:56.365] -> Delete data prior to: 2011-06-16
[INFO] [14:01:56.375] -> Clean MEDIATION-DEV1_SMED-Apporteur [id=4094]
[INFO] [14:01:56.387] <- Delete aborted builds
[INFO] [14:01:56.491] <- Clean snapshot 7289
[INFO] [14:01:56.646] Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
[INFO] [14:01:56.647] Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.157 s
[INFO] Finished at: 2016-06-09T14:01:56+02:00
[INFO] Final Memory: 23M/428M
[INFO] ------------------------------------------------------------------------

当我浏览给定地址时,(已配置)仪表板中不会显示任何结果。

你知道吗?

当做

托马斯

共有1个答案

夏星阑
2023-03-14

SonarQube是一个源代码分析器。根据定义,它所做的一切(创建度量、问题...)都必须附加到源文件。因此,如果您没有项目的源(在日志中可见:0 file index),那么在项目看板中没有任何内容是正常的。

 类似资料:
  • 在Jenkins中运行分析时,我得到了这个错误: 干杯。

  • xccov工具仅为覆盖的代码行生成单元测试覆盖率报告。如果你举个例子。swift文件有20行,10行由单元测试覆盖,覆盖率为50%。 Karma(用于Angular 2开发)不仅为所涵盖的代码行创建报告,还为语句、分支和函数创建报告。 是否可以配置xccov,或者在iOS开发中是否有类似的工具来实现这一点?谢谢

  • 问题内容: 有一个jenkins的声纳插件,它会触发CI(jenkins)内部的声纳构建,非常有用。 虽然现在我想在詹金斯内部查看声纳结果而无需跳转到声纳网站,但如果我只想查看此工作的一些关键数据,这将非常有用。 它可能是詹金斯中的声纳报告插件。 您有类似的需求吗? 问题答案: 到目前为止,我使用的一个丑陋的解决方案是使用Sonar Web API。 我在工作结束时添加一个命令(构建步骤)以获取所

  • 我用两种方法对一个项目进行了声纳分析 > 作为maven的目标,使用(Java1.8)和(java 1.6) 两次扫描都产生了两份不同的报告。我不知道为什么会这样。 下面是我的开发环境配置 Maven: 3.0.5声纳方块: 3.0.1声纳转轮: 2.4日食:开普勒Java: 1.6

  • 我已经看了一段时间关于stackoverflow的不同文章和答案,但我还没有找到适合我的情况的有效解决方案。我对jacoco、maven和sonar如何一起创建报告的理解肯定有问题,所以我要寻求帮助。 我有一个多模块maven项目,其结构如下(稍微简化了一下): 请允许我扩展一下。父模块只是一个带有整个依赖项及其版本的pom。这个pom被用作level1的每一个其他模块的父模块(直接位于根下面)。