我想在我的声纳分析中使用jococco代码覆盖,因为我已经下载了jococo jar和代理jar以及jococo的maven插件jar,因为我的项目是基于ant的,所以我将这些文件保存在我的类路径中在ant home lib中,现在我正在使用以下标签进行声纳中的代码覆盖,但我仍然认为错误是.. Project coverage is set to 0% as no JaCoCo execution data has been dumped:
,请告知如何克服此错误,FOLKS PLEESE ADVISE
我的构建xml为下面显示的声纳标记中的ant指定了以下任务。
<property key="sonar.java.coveragePlugin" value="jacoco" />
<property key="sonar.junit.reportsPath" value="${ps}/test-acceptance/com/sfm/ice/oa/report"/>
<property key="sonar.jacoco.reportPath" value="${ps}/jacoco/jacoco-ut.exec" />
<property key="sonar.jacoco.itReportPath" value="${ps}/jacoco/jacoco-it.exec" />
<property key="sonar.jacoco.itReportPath" value="${ps}/jacoco/jacoco-it.exec" />
和日志我可以看到如下所示的错误..
15:33:31.427 INFO - Retrieve SCM blame information with encoding UTF-8 done: 12742 ms
[20:03:31]15:33:31.431 INFO - Sensor ScmActivitySensor done: 12749 ms
[20:03:31]15:33:31.431 INFO - Sensor CpdSensor...
[20:03:31]15:33:31.432 INFO - SonarEngine is used
[20:03:31]15:33:31.664 INFO - Cross-project analysis disabled
[20:03:40]15:33:40.717 INFO - Sensor CpdSensor done: 9286 ms
[20:03:40]15:33:40.719 INFO - Sensor PmdSensor...
[20:03:40]15:33:40.721 INFO - Execute PMD 4.3...
[20:03:40]15:33:40.737 INFO - Java version: 1.5
[20:03:41]15:33:41.076 INFO - PMD configuration: /opt/app/glacier/buildAgent-8.0.3/work/Glacier/build/pmd.xml
[20:04:24]15:34:24.639 INFO - Execute PMD 4.3 done: 43918 ms
[20:04:24]15:34:24.850 INFO - Sensor PmdSensor done: 44131 ms
[20:04:24]15:34:24.850 INFO - Sensor JaCoCoItSensor...
[20:04:24]15:34:24.856 INFO - Project coverage is set to 0% as no JaCoCo execution data has been dumped: /opt/app/glacier/buildAgent-8.0.3/work/Glacier/${ops}/jacoco/jacoco-it.exec
[20:04:26]15:34:26.203 INFO - No information about coverage per test.
[20:04:26]15:34:26.203 INFO - Sensor JaCoCoItSensor done: 1353 ms
[20:04:26]15:34:26.204 INFO - Sensor JaCoCoOverallSensor...
[20:04:26]15:34:26.204 INFO - Sensor JaCoCoOverallSensor done: 0 ms
[20:04:26]15:34:26.205 INFO - Sensor SurefireSensor...
[20:04:26]15:34:26.206 INFO - parsing /opt/app/glacier/buildAgent-8.0.3/work/Glacier/${ops}/test-acceptance/com/rbsfm/ice/ioa/report
[20:04:26]15:34:26.207 INFO - Sensor SurefireSensor done: 2 ms
[20:04:26]15:34:26.207 INFO - Sensor CheckstyleSensor...
[20:04:26]15:34:26.209 INFO - Execute Checkstyle 5.6...
[20:04:26]15:34:26.218 INFO - Checkstyle configuration: /opt/app/glacier/buildAgent-8.0.3/work/Glacier/build/checkstyle.xml
[20:04:31]15:34:31.581 INFO - Execute Checkstyle 5.6 done: 5372 ms
[20:04:31]15:34:31.586 INFO - Sensor CheckstyleSensor done: 5379 ms
[20:04:31]15:34:31.587 INFO - Sensor InitialOpenIssuesSensor...
[20:04:34]15:34:34.650 INFO - Sensor InitialOpenIssuesSensor done: 3063 ms
[20:04:34]15:34:34.651 INFO - Sensor ProfileSensor...
[20:04:35]15:34:35.308 INFO - Sensor ProfileSensor done: 657 ms
[20:04:35]15:34:35.309 INFO - Sensor ProfileEventsSensor...
[20:04:35]15:34:35.319 INFO - Sensor ProfileEventsSensor done: 10 ms
[20:04:35]15:34:35.320 INFO - Sensor ProjectLinksSensor...
[20:04:35]15:34:35.333 INFO - Sensor ProjectLinksSensor done: 13 ms
[20:04:35]15:34:35.334 INFO - Sensor VersionEventsSensor...
[20:04:35]15:34:35.385 INFO - Sensor VersionEventsSensor done: 51 ms
[20:04:35]15:34:35.386 INFO - Sensor com.headway.plugins.sonar.S101Sensor@3ca021e3...
[20:04:35]15:34:35.415 INFO - Sensor com.headway.plugins.sonar.S101Sensor@3ca021e3 done: 29 ms
[20:04:35]15:34:35.416 INFO - Sensor JaCoCoSensor...
[20:04:35]15:34:35.419 INFO - Project coverage is set to 0% as no JaCoCo execution data has been dumped: /opt/app/hhh/buildAgent-8.0.3/work/hhh/${ops}/jacoco/jacoco-ut.exec
[20:05:14]15:35:14.613 INFO - No information about coverage per test.
[20:05:14]15:35:14.615 INFO - Sensor JaCoCoSensor done: 39199 ms
[20:05:15]15:35:15.444 INFO - Execute decorators...
答案 0 :(得分:0)
我们使用Ant构建成功地使用jacoco进行SonarQube的单元测试覆盖。我无法从您的片段中看出您是通过Ant构建执行单元测试,还是希望SonarQube为您执行它们。我们让Jenkins执行构建步骤,在执行SonarQube分析的Jenkins步骤之前单独执行单元测试(并收集jacoco覆盖数据)。
也就是说,看起来我在你的代码片段和我们在build.xml中看到的内容之间的主要区别是属性名称:我们有sonar.core.codeCoveragePlugin,这不是你正在使用的。
<property name="sonar.dynamicAnalysis" value="reuseReports"/>
<property name="sonar.surefire.reportsPath" value="${test.log.dir}"/>
<property name="sonar.junit.reportsPath" value="${test.log.dir}"/>
<property name="sonar.sources" value="${src.dir}" />
<property name="sonar.tests" value="${test.src.dir}" />
<property name="sonar.binaries" value="${classes.dir}" />
<property name="sonar.core.codeCoveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="${test.log.dir}/jacoco.exec"/>
埋在我们的“测试”目标中是这样的:
<jacoco:coverage enabled="${my.coverage.enabled}" destfile="${test.log.dir}/jacoco.exec">
<junit printsummary="true"
fork="yes"
...
</junit>
</jacoco:coverage>
</target>
希望有所帮助。