Maven – Jacoco and Sonar code coverage

jacocoJenkinsmavenselenium-rcsonarqube

Using : JaCoCo 0.5.3, Maven2, Sonar 2.14, sonar-maven-plugin 1.8, SùartGWT 3.0
Currently trying to : Get code coverage on Sonar of my Selenium unit tests.
Problem : Code coverage doesn't move from 0% although the sensor is launched properly, analyse the jacoco.exec which is correctly generated.
Ressources : https://gist.github.com/2888912 The pom.xml

It's been about 2 weeks I'm trying to get code coverage. I upgraded the Sonar from 2.10 to 2.14, changed every single sonar property, tried the plugin jacoco (for maven) and I still DON'T get any results. So if someone had the same problems and found the solution, could you please tell me how you amde it work ?

I'm quite sure my tests must generate at least 0.5% of code coverage. My Selenium tests are actually executed in SeleniumTestLoginEntry.java, does it have any incidence ? Must I call it TestLoginEntry.java ? (The tested class is LoginEntry.java)
I'm using surefire to start the javaagent of JaCoCo (see the tag) and it actually GENERATES the jacoco.exec.

Please give me some help, I'm totally lost I have only one week left to make it work… 🙁
Thanks in advance.

Best Answer

I'm in a slightly different setup than you are, using Ant and Sonar 3.01, but... there was one property that did the trick for me, that seemed to be almost entirely undocumented when I looked. I notice the wiki pages have had updates in the last couple of days, which may have changed the doc situation.

<property name="sonar.core.codeCoveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="${test.log.dir}/jacoco.exec"/>

Setting sonar.jacoco.reportPath explicitly to the file, not a directory, was what finally worked for me.