Reputation: 34293
I'm having a hard time getting the unit test coverage in Eclipse 3.8.1 with the SonarQube plugin 3.3.0.
I'm executing SonarQube on my Gradle project. Everything works fine except for JaCoCo's report.
Here's the console output from a SonarQube analysis:
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
The part near the bottom bugs me:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/siberut/workspace/Utils/build/test-results/jacoco.exec
These are the properties I've set for the analysis:
It'd be great if someone could give me a hint on what's missing here. Thanks.
Upvotes: 1
Views: 2534
Reputation: 1216
This is similar to other question here SonarQube does not collect code coverage.
You need to configure Gradle with the jacoco plugin, take a look to Jacoco Plugin and adapt it to your needs, i.e.
test {
jacoco {
append = false
destinationFile = file("$buildDir/tests-results/jacoco.exec")
classDumpFile = file("$buildDir/tests-results/classpathdumps")
}
}
And run build/test with gradle prior to SonarQube analysis
Upvotes: 2
Reputation: 1
For your Surefire plugin, do you have the property <forkMode>
set? When this is set to never
it can cause the issue you are facing. Change to either once
or pertest
.
See Sonar documentation for details.
I am encountering a similar issue, but instead of the error, "Project coverage is set to 0% as no JaCoCo execution data has been dumped:", I am seeing:
Project coverage is set to 0% since there is no directories with classes.
Any ideas would be appreciated.
Upvotes: 0