Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I integrate Jacoco reports with SonarQube without using maven?

I used Jacoco eclipse plugin to measure unit test coverage and I was able to export a report using it. I want to integrate that report with sonar so I gave the path to it in the project properties file. My properties file looks like this

# Required metadata
sonar.projectKey=key
sonar.projectName=name
sonar.projectVersion=1.0
sonar.jacoco.reportPath=jacoco.exec
sonar.tests=junit
sonar.dynamicAnalysis=reuseReports
sonar.java.coveragePlugin=jacoco
sonar.jacoco.reportMissing.force.zero=true
# Comma-separated paths to directories with sources (required)
sonar.sources=src

# Comma-separated paths to directories with tests (optional)
sonar.tests=test

# Encoding of the source files
sonar.sourceEncoding=UTF-8

# Language
sonar.language=java

When I executed sonar-runner the following lines were there in the console output

16:23:13.219 INFO  - Sensor JaCoCoItSensor...
16:23:13.219 INFO  - No JaCoCo analysis of project coverage can be done since there is no class files.
16:23:13.219 INFO  - Sensor JaCoCoItSensor done: 0 ms
16:23:13.219 INFO  - Sensor JaCoCoOverallSensor...
16:23:13.219 INFO  - Sensor JaCoCoOverallSensor done: 0 ms
16:23:13.219 INFO  - Sensor JaCoCoSensor...
16:23:13.219 INFO  - No JaCoCo analysis of project coverage can be done since there is no class files.

Also the unit test coverage widget indicated "No Data". Why am I not able to get Sonar to display the coverage results? What is the correct way to do this? This is my first experience with Jacoco and I'm also new to Sonar, so detailed guides are very much appreciated.

like image 543
nekoMiaChan Avatar asked Jan 05 '15 11:01

nekoMiaChan


People also ask

Which tool is used to analyze the code coverage in SonarQube?

For Java projects, SonarQube directly supports the JaCoCo coverage tool (see Generic Test Data for information on integrating other coverage tools).

How does SonarQube get code coverage?

SonarQube itself does not calculate coverage. To include coverage results in your analysis, you must set up a third-party coverage tool and configure SonarQube to import the results produced by that tool. Below, you'll find guidelines and resources, as well as language- and tool-specific analysis parameters.

What is the difference between sonar and JaCoCo?

SonarQube has a broader approval, being mentioned in 163 company stacks & 271 developers stacks; compared to JaCoCo, which is listed in 5 company stacks and 11 developer stacks.


1 Answers

You must specify "sonar.binaries" property that points to the folder where your classes are compiled.

like image 103
Fabrice - SonarSource Team Avatar answered Oct 24 '22 20:10

Fabrice - SonarSource Team