Generating code coverage report in Clover XML format ... done
but sonar is showing 0% code coverage
Related
We're using Sonar Server 9.1 and using maven command to publish reports to Sonar along with code coverage generated through Jacoco
In index.html file generated for code coverage, we can see code coverage as - 68% but used jacoco.xml file to publish to Sonar it's showing only 48.6% code coverages.
What analysis I should do to find the cause of discrepancy?
Sonarqube server 6.7.7
Sonar scanner 4.6.2
sonar-project.properties
sonar.java.binaries=target/classes
#sonar.junit.reportsPath=target/surefire-reports
#sonar.surefire.reportsPath=target/surefire-reports
#sonar.jacoco.reportPaths=target/jacoco.exec
sonar.coverage.jacoco.xmlReportPaths=/target/site/jacoco/jacoco.xml
sonar.java.coveragePlugin=jacoco
sonar.verbose=true
Note: I used the jacoco.xml or the jacoco.exec still not able to display
sonarqube dashboard showing no code coverage
Is it possible to calculate code coverage with maven 2 and sonar scanner 2.8/2.9?
Yes, but Sonar Scanner is not responsible for generating code coverage. It only process reports generated by other tools, e.g.:
EclEmma JaCoCo Java Code Coverage Library
Atlassian Clover
Cobertura
...
Example how to use JaCoCo with Java Plugin: https://docs.sonarqube.org/display/PLUG/Usage+of+JaCoCo+with+Java+Plugin
I recently upgraded to SonarQube 5.3 and now test coverage using Cobertura is no longer published/analyzed.
It looks like JaCoCo is default code coverage no matter what we install or configure. Log shows that SonarQube is looking and not finding JaCoCo reports.
Is there still support for Cobertura with 5.3?
I tried to configure cobertura but sonar.java.coveragePlugin does not seem to do much anymore. You can specify what you like using this property but the JaCoCo will be used.
[INFO] JaCoCoSensor: JaCoCo report not found : E:\myproject\jacoco.exec
[INFO] JaCoCoItSensor: JaCoCo IT report not found: E:\myproject\jacoco-it.exec
Since SonarQube 4.2 the test report isn’t generated by SonarQube anymore (see SonarQube blog post for more information). So you have to do it by your own before you run the sonar analyze. For Maven builds, I wrote a sample how to integrate JaCoCo test reporting generation into a Maven build.
For Cobertura, you have to install the Cobertura Plugin for SonarQube. On that site it is explained how to generate the reports.
I am trying to analyze the code and unit test coverage using Sonar, Cobertura and ANT. But somehow it is showing dash ("-") under "Unit Test Coverage" on sonar dashboard. Even it shows "Unit Test Success" as 100%.
I am using following versions:
Sonar: 4.4
Cobertura: 1.6.2
Junit4
Can you please help me to understand the root cause of the issue?