Domanda

I am having a issue with generating code coverage report and getting an analysis of unit tests covering the project code. I have used Sonar to get a report on project but the unit test coverage section do not show anything. I have done some research and found that sonar needs to have a junit report generated by emma/clover/corbetura/jacoco. The project is non-maven based. Please tell me how can I analyse code coverage for a non-maven based multi-module project. I am using sonar runner.

Any link or reference will be helpful. Please do not give links of documentation pages. Apparently, I have browsed them all. Thanks in advance.

È stato utile?

Soluzione

I'm giving the links to the documentation pages to help others who have not seen the documentation or examples. Take the maven property settings and translate them into sonar-runner.properties. For example, depending on how you set up your multi-module project you might put this setting in the parent level or inside each module: sonar.jacoco.reportPath=reports/coverage/jacoco.exec

Here is the link to the multi-module sonar runner project:

http://docs.codehaus.org/display/SONAR/Analyzing+with+SonarQube+Runner

To configure unit test code coverage apply the same properties in maven to the sonar-project.properties file. Here is the example from the Code Coverage example:

https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage

Note you need to set the unit and coverage properties as well as the source encoding properties.

 
    sonar.projectKey=org.codehaus.sonar:example-ut-sonarRunner-jacoco-reuseReports
    sonar.projectName=UT coverage with SonarQube Runner reusing JUnit and JaCoCo reports
    sonar.projectVersion=1.0

    sonar.sources=src
    sonar.binaries=classes
    sonar.language=java

    # Tells SonarQube to reuse existing reports for unit tests execution and coverage reports
    sonar.dynamicAnalysis=reuseReports

    # Tells SonarQube where the unit tests execution reports are
    sonar.junit.reportsPath=reports/junit

    # Tells SonarQube that the code coverage tool by unit tests is JaCoCo
    sonar.java.coveragePlugin=jacoco

    # Tells SonarQube where the unit tests code coverage report is
    sonar.jacoco.reportPath=reports/coverage/jacoco.exec

    # Encoding of the source files
    sonar.sourceEncoding=UTF-8
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top