Andreas Gryphius
Andreas Gryphius

Reputation: 193

SonarQube 5 with JaCoCo 0.0% Coverage, why?

I struggle since days getting JaCoCo report integrated in SonarQube 5.0.1 for our project. Always I read 0.0% coverage in SonarQube.

TeamCity 9 generated a testresults.xml and a jacoco.exec file which I use for the sonar runner. TeamCity displays the coverage, so the exec file seams to be okay. And Java code analysis works basically in SonarQube (FindBugs, PMD etc.)

I have a multi module project which is still build with Ant. The unit tests for the "core" project are in an own project called "junit". The JUnit 4 library is used, but the tests are still JUnit 3.

These are the relevant (?) properties I use in a file called "sonar-project.properties":

core.sonar.tests                           = ../junit/src
core.sonar.junit.reportsPath               = /tmp/testresults.xml
core.sonar.core.coveragePlugin             = jacoco
core.sonar.jacoco.reportMissing.force.zero = false
core.sonar.jacoco.reportPath               = /tmp/jacoco.exec

The property prefix "core" is because they are configuring the module "core".

Paths should be correct. But it says: "WARN - Reports path not found: /tmp/testresults.xml" The path is correct, I don't know why this warning appears.

Do I need binaries for the coverage in SonarQube? I haven't compiled the code.

Or what could be the reason that SonarQube displays 0% coverage after I run sonar-runner?

Upvotes: 2

Views: 3403

Answers (1)

benzonico
benzonico

Reputation: 10833

First: /tmp/testresults.xml this has nothing to do with coverage, but with test results import (number of tests, success tests).

Do I need binaries for the coverage in SonarQube? I haven't compiled the code.

The answer to your question lies in this interrogation : Yes. In order to compute coverage when reading the .exec JaCoCo report file, JaCoCo analyzer (used in the java plugin) requires the .class file input stream, therefore bytecode is required to import JaCoCo reports. So please compile your project and provide the class files through sonar.java.binaries property.

Upvotes: 1

Related Questions