我很难用SonarQube插件3.3.0在Eclipse 3.8.1中获得单元测试覆盖率。
我正在Gradle项目上执行SonarQube。除了JaCoCo的报告外,一切正常。
以下是SonarQube分析的控制台输出:
Retrieve remote issues of project Utils...
Start SonarQube analysis on Utils...
INFO: SonarQube Server 4.1.1
23:52:07.236 INFO - Incremental mode
23:52:07.247 INFO - Load batch settings
23:52:07.471 INFO - User cache: /home/siberut/.sonar/cache
23:52:07.517 INFO - Install plugins
23:52:07.550 INFO - Exclude plugins: devcockpit, jira, pdfreport, views, report, scmactivity
23:52:08.123 INFO - Create JDBC datasource for jdbc:h2:/home/siberut/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/Utils/org.sonar.ide.eclipse.core/.sonartmp/preview1392763927919-0
23:52:10.330 INFO - Initializing Hibernate
23:52:14.497 INFO - Load project settings
23:52:14.563 INFO - Apply project exclusions
23:52:14.959 INFO - ------------- Scan Utils
23:52:14.967 INFO - Load module settings
23:52:15.686 INFO - Quality profile : [name=Sonar way,language=java]
23:52:15.711 INFO - Excluded tests:
23:52:15.712 INFO - **/package-info.java
23:52:15.838 INFO - Index files
23:52:16.008 INFO - 27 files indexed
23:52:16.024 INFO - Loading technical debt model...
23:52:16.600 INFO - Loading technical debt model done: 576 ms
23:52:16.625 INFO - Configure Maven plugins
23:52:16.908 INFO - Compare to previous analysis (2014-02-18)
23:52:16.926 INFO - Compare over 30 days (2014-01-19, analysis of 2014-02-16 15:53:15.0)
23:52:16.937 INFO - Compare to previous version (2014-02-18)
23:52:17.297 INFO - Base dir: /home/siberut/workspace/Utils
23:52:17.300 INFO - Working dir: /home/siberut/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/Utils/org.sonar.ide.eclipse.core
23:52:17.301 INFO - Source dirs: /home/siberut/workspace/Utils/src/main/java, /home/siberut/workspace/Utils/src/main/resources
23:52:17.302 INFO - Test dirs: /home/siberut/workspace/Utils/src/test/java, /home/siberut/workspace/Utils/src/test/resources
23:52:17.304 INFO - Binary dirs: /home/siberut/workspace/Utils/bin
23:52:17.305 INFO - Source encoding: UTF-8, default locale: en_US
23:52:17.330 INFO - Sensor JavaSourceImporter...
23:52:17.408 INFO - Sensor JavaSourceImporter done: 78 ms
23:52:17.412 INFO - Sensor JavaSquidSensor...
23:52:17.807 INFO - Java AST scan...
23:52:17.825 INFO - 2 source files to be analyzed
23:52:18.426 INFO - 2/2 source files analyzed
23:52:18.437 INFO - Java AST scan done: 630 ms
23:52:18.441 INFO - Java bytecode scan...
23:52:18.937 INFO - Java bytecode scan done: 496 ms
23:52:18.957 INFO - Package design analysis...
23:52:18.970 INFO - Package design analysis done: 13 ms
23:52:19.008 INFO - Sensor JavaSquidSensor done: 1596 ms
23:52:19.008 INFO - Sensor SurefireSensor...
23:52:19.012 INFO - parsing /home/siberut/workspace/Utils/build/test-results
23:52:19.283 INFO - Sensor SurefireSensor done: 275 ms
23:52:19.285 INFO - Sensor CpdSensor...
23:52:19.286 INFO - SonarEngine is used
23:52:19.288 INFO - Cross-project analysis disabled
23:52:19.478 INFO - Sensor CpdSensor done: 193 ms
23:52:19.478 INFO - Sensor PmdSensor...
23:52:19.483 INFO - Execute PMD 4.3...
23:52:19.500 INFO - Java version: 1.7
23:52:19.649 INFO - PMD configuration: /home/siberut/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/Utils/org.sonar.ide.eclipse.core/pmd.xml
23:52:21.042 INFO - Execute PMD 4.3 done: 1559 ms
23:52:21.045 INFO - Sensor PmdSensor done: 1567 ms
23:52:21.046 INFO - Sensor InitialOpenIssuesSensor...
23:52:21.129 INFO - Sensor InitialOpenIssuesSensor done: 83 ms
23:52:21.136 INFO - Sensor ProfileSensor...
23:52:21.377 INFO - Sensor ProfileSensor done: 241 ms
23:52:21.378 INFO - Sensor ProfileEventsSensor...
23:52:21.410 INFO - Sensor ProfileEventsSensor done: 32 ms
23:52:21.411 INFO - Sensor ProjectLinksSensor...
23:52:21.447 INFO - Sensor ProjectLinksSensor done: 36 ms
23:52:21.450 INFO - Sensor JaCoCoSensor...
23:52:21.468 INFO - Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/siberut/workspace/Utils/build/test-results/jacoco.exec
23:52:21.767 INFO - Sensor JaCoCoSensor done: 317 ms
23:52:22.306 INFO - Execute decorators...
23:52:23.500 INFO - Export results to /home/siberut/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/Utils/org.sonar.ide.eclipse.core/sonar-report.json
23:52:23.513 INFO - Store results in database
23:52:23.795 INFO - ANALYSIS SUCCESSFUL
靠近底部的部分让我感到困惑:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/siberut/workspace/Utils/build/test-results/jacoco.exec
这些是我为分析设置的属性:
如果有人能给我一些关于这里缺少什么的提示,那就太好了。 感谢。
答案 0 :(得分:2)
这与此处SonarQube does not collect code coverage的其他问题类似。
您需要使用jacoco插件配置Gradle,查看Jacoco Plugin并根据您的需要进行调整,即
test {
jacoco {
append = false
destinationFile = file("$buildDir/tests-results/jacoco.exec")
classDumpFile = file("$buildDir/tests-results/classpathdumps")
}
}
在 SonarQube分析
之前使用gradle 运行构建/测试答案 1 :(得分:0)
对于您的Surefire插件,您是否设置了属性<forkMode>
?如果将其设置为never
,则可能会导致您遇到的问题。更改为once
或pertest
。
有关详细信息,请参阅Sonar documentation。
我遇到了类似的问题,但不是错误,“项目覆盖率设置为0%,因为没有转储JaCoCo执行数据:”,我看到了:
项目范围设置为0%,因为没有包含类的目录。
任何想法都会受到赞赏。