Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage percentage values in Jacoco eclipse plug-in and SonarQube are different

I have a Java project. The code coverage of that project according to Jacoco eclipse plug-in (EclEmma Java Code Coverage 2.3.1.201405111647) is 22.3%. I generate the .exec report and feed it to SonarQube and run an analysis with sonar runner. The code coverage shown on SonarQube's web interface as a result is 20.2%. The coverage values at package level are also different to what shown by Jacoco's eclipse plug-in. How is that possible? Isn't SonarQube taking values from the .exec report generated by Jacoco?

like image 363
umairaslam Avatar asked Nov 10 '22 03:11

umairaslam


1 Answers

Jacoco is based on bytecode analysis. The exec file is combined with the class files to get the final code coverage values. The problem in my case was that the bytecode generated by Eclipse compiler for Java (for Jacoco eclipse plug-in) and that produced by Javac (during analysis on sonar runner) were different. Hence, the code coverage values generated by both tools were different.

like image 181
umairaslam Avatar answered Nov 14 '22 21:11

umairaslam