Sonarqube is not showing code coverage after running

Tarun Maganti picture Tarun Maganti · May 24, 2017 · Viewed 46.8k times · Source

I'm running sonarqube with maven.

I have installed it using following way. Using brew, I installed mysql and sonar.

When I run I get 7 critical bugs but the code coverage for 88 tests is zero Sonarqube analysis

When I run it with IntelliJ's tools, I get the following results. (not zero!) IntelliJ analysis

This is when I check Jacoco results directly. In $base_direc/target/jacoco/index.html
Jacoco results

The same code when run with sonar-scannersonar-scanner


This is my maven configuration
maven configuration

My ~/.m2/settings.xml
settings-pic1
settings-pic2


Edit 1: I have found this in logs. Db not supported


Edit2: I have edited ~/.m2/settings.xml added

<properties>
    <sonar.host.url>http://localhost:9000/</sonar.host.url>
</properties>

Edited /usr/local/Cellar/sonarqube/6.3.1/libexec/conf/sonar.properties added sonar.host.url=http://localhost:9000/

Edited /usr/local/etc/sonar-scanner.properties added - sonar.host.url=http://localhost:9000/

Ran the application in all above ways and the results were same, i.e, I could see Jacoco results but not in sonar.


Is it possible that if bugs are found sonar refuses to do code coverage?!

Answer

Tarun Maganti picture Tarun Maganti · May 25, 2017

I found the solution -

The maven plugin I have included has configuration of Jacoco's destfile and datafile as ${basedir}/target/coverage-reports/jacoco-unit.exec

but by default sonar reads at ${basedir}/target/jacoco.exec. I changed the default at http://localhost:9000/settings?category=java


Ref: Sonar Code Coverage