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?
Related
I have configured Jenkins 2.31.1 with Maven 3.3.9 , and I am using Sonarqube 5.6.4, when I am building my Java project from Jenkins then test cases are getting executed also I am getting report in Sonarqube but Unit Tests Coverage is coming as "-".
Can anyone explain the steps to resolve this issue? How can I get Unit Tests Coverage? What are the changes I need to do ? What are the steps to be followed? Am I missing something here?
Here is link to my git repository -
https://github.com/swapnil0504/HelloFromMaven.git
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.
There was a known issue from 2014 that UnitTests written in Groovy cannot have their PASS/FAIL metrics uploaded into SonarQube.
http://sonarqube-archive.15.x6.nabble.com/Resource-not-found-for-Groovy-unit-tests-td5024669.html
Does anyone know if this issue is fixed? I am still have the issue with Sonar 6.1 using Spock unit tests and Gradle build system.
Any clue on the correct gradle sonar settings to make this happen?
The solution for us was to install the Groovy plugin in Sonarqube 6.1.
Once the plugin was installed, we could see the tests, with this command line:
./gradlew sonarqube -Dsonar.tests=src/test/groovy -Dsonar.junit.reportsPath=build/test-results/test/
We are using Spock as well (with Gradle, as you can see)
I am using Maven to run EUnit tests on my Erlang project and then making a static code analysis. I do not know how to configure the coverage report path so that SonarQube could also show my code coverage results.
In your Maven goals, append the following
-Dsonar.erlang.eunit.reportsfolder=PATH-TO-YOUR-REPORT-FILES
For me following setting worked
-Dsonar.erlang.eunit.reportsfolder=_build/test/cover
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.