我配置了一个Jenkins版本来运行SonarQube,我看到除代码覆盖范围外的所有结果。我可以在surefire-reports目录中看到xml和txt文件,我也看到jacoco.exec,所以我对我缺少的东西感到困惑,我怀疑它会是超级基础。单元测试结果没有在SonarQube中显示
SonarQube版本:6.3.1 詹金斯:2.46.2
这是我SonarQube配置在詹金斯:
# metadata
sonar.projectName=${JOB_NAME}
sonar.projectVersion = 0.1
#path to source
sonar.projectBasedDir=${WORKSPACE}
sonar.sources=src/... (removed specific path)
sonar.binaries=target/classes
#report location
sonar.junit.reportPaths=${project.build.directory}/target/surefire-reports sonar.jacoco.reportPaths=${project.build.directory}/target/surefire-reports/jacoco.exec
#testing parms
sonar.verbose=true
sonar.tests=src/test/java
sonar.language=java
这里是我的POM插件数据:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<argLine>${argLine}</argLine>
<runOrder>random</runOrder>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<destFile>${basedir}/target/surefire-reports/jacoco.exec</destFile>
<dataFile>${basedir}/target/surefire-reports/jacoco.exec</dataFile>
<output>file</output>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.20</version>
</dependency>
可以为您包括您所使用做你的扫描maven的命令? – Tim
@Tim我正在使用mavem目标 - 清洁测试包 – ApolloRaptor
我正在比较你的pom和我的一些。我使用maven-surefire插件,而不是你使用的apache(如果这有什么区别的话)。但要做扫描,“mvn -U clean org.jacoco-maven-plugin:prepare-agent install org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar -Dsonar.host.url = http://<我的声呐主机:9000>“ – Tim