我正在尝试计算我的单元测试和放大器的代码覆盖率。功能测试。 运行我的单元测试后,我生成jacoco.exec文件。 类似地,对于功能测试,我得到jacoco-it.exec文件。
现在我想提供这些文件作为声纳的输入,如下所示:
mvn sonar:sonar -Dsonar.jdbc.url =“jdbc:mysql:// localhost:3306 / sonar?useUnicode = true& characterEncoding = utf8”-Dsonar.jdbc.username = sonar -Dsonar.jdbc.password = sonar -Dsonar.host.url = http://localhost:9000 -Dsonar.jacoco.reportPath = jacoco.exec -Dsonar.jacoco.itReportPath = jacoco-it.exec
但声纳在仪表板上产生0%的覆盖率。 有没有其他方法我可以从jacoco.exec文件计算覆盖率,而不提供我的源代码/二进制文件来分析它?
答案 0 :(得分:0)
What is the configuration of jacoco in your pom.xml ?
Have you check the path of you report ?
The sample code from sonarqube showing how to have UT, IT and coverage using Jacoco: http://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Integration+Tests+for+Java+Project
And I think setting properties in pom.xml is better than use -D parameter ...
<properties>
<!-- select JaCoCo as a coverage tool -->
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<!-- force sonar to reuse reports generated during build cycle -->
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<!-- set path for unit tests reports -->
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-unit.exec</sonar.jacoco.reportPath>
<!-- all modules have to use the same integration tests report file -->
<sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
</properties>