我配置了一個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