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?
Related
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
I just upgraded my sonar installation from 5.6 to 6.1.
Before the database had test coverage for java projects and the measures associated.
If I go to a project the page of the project only shows Bugs&vulnerabilites, code smells and duplications.
Even after rerunning the coverage with jenkins (same method as previous run) the coverage is not shown. Jenkins do report coverage as usual.
Also no test coverage info is shown in the code.
I verified:
- Installation is done correctly. Database upgrade is done correctly
- Look at not rerun projects (no test coverage)
- Rerun one project, test coverage not to be seen in that project
- Jenkins does report test coverage
- I upgraded the sonar plugin from 2.4.1 to 2.5 and rerun the analysis. No test coverage available.
The sonar.junit.reportsPath does point to the jacoco.exec file
In the same directory a lot of TEST....txt files are present (no xml)
What am I missing? It worked in 5.6.
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 using Maven with jenkins and sonar to build src and generate reports on Sonar.
I see build was successful in Jenkins (sonar added as post build action) but fails to create coverage.xml in local system. Due to which code coverage is unavailable in Sonar, it just shows up -(empty). I am building a project which has around 4000+ java source files and corresponding JUnit classes.
I am using cobertura-maven-plugin 2.5.1 in pom.xml and I could see this plugin instrumentation was successful while building the code.
In logs I could see that, Cobertura report not found at //coverage.xml message.
Could you please help me on this regard.
coverage.xml was not generated due to OutOfMemeryError:heapspace. Since my project is such a big project when I set heap memory to 2GB and cobertura plugin memory to 1.5GB sonar gets code coverage displayed.
Heap memory set with Jenkins post build action sonar configuration.
Cobertura memory can be configured either in Sonar settings or in your pom.xml.
I have a cobertura.ser file, that got generated while integration-test and system test. Now I want to import my coverage this to sonar server.
How can I achieve this, so while executing mvn sonar:sonar the coverage should consider external coberture.ser file?
Can I do this using sonar, where i can see overall coverage obtain during all test run?
You need to set the following paramater to tell Sonar to use a pre-generated report:
sonar.dynamicAnalysis=reuseReports
Secondly Sonar doesn't read the "cobertura.ser" file. It can be configured as follows to read the generated XML report (See cobertura docs):
sonar.cobertura.reportPath=target/reports/coverage.xml
Finally, my reference for all this stuff comes from the from the Sonar wiki:
http://docs.codehaus.org/display/SONAR/Advanced+Parameters
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests
The Sonarsource tutorials are increasingly pushing JaCoCo. This appears to be an emerging standard (replacing the older defunct Emma project)