# Zero Coverage SonarQube, even though JaCoCo generated all files

**URL:** <https://community.sonarsource.com/t/zero-coverage-sonarqube-even-though-jacoco-generated-all-files/32002>\
**Category:** SonarQube Server / Community Build\
**Tags:** maven, java\
**Created:** [September 28, 2020, 9:21am UTC](https://community.sonarsource.com/t/zero-coverage-sonarqube-even-though-jacoco-generated-all-files/32002 "2020-09-28T09:21:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roko](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@roko](https://community.sonarsource.com/u/roko)\
**Post date:** [September 28, 2020, 9:21am UTC](https://community.sonarsource.com/t/zero-coverage-sonarqube-even-though-jacoco-generated-all-files/32002/1 "2020-09-28T09:21:54Z")

</div>

Hi community,

I am having trouble with Sonar reading the coverage information from test result. The version of Sonar I am using is 7.9.2, and the parts of my pom files that refer to sonarqube and jacoco are:

```
<properties>
    <!-- Sonar -->
    <skipTests>false</skipTests>
    <sonar.projectKey>test-service</sonar.projectKey>
    <sonar.projectName>test-service</sonar.projectName>
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <project.test.result.directory>${project.build.directory}/test-results</project.test.result.directory>
    <sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
    <sonar.coverage.jacoco.xmlReportPaths>${project.test.result.directory}/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
    <sonar.language>java</sonar.language>
</properties>
...
 <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
      ...
 </dependencies>
 <build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.7.0.1746</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M4</version>
            <configuration>
                <argLine>${jacocoArgLine}</argLine>
                <reportsDirectory>${project.test.result.directory}/surefire</reportsDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.5</version>
            <executions>
                <execution>
                    <id>pre-test</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <propertyName>jacocoArgLine</propertyName>
                        <destFile>${project.test.result.directory}/jacoco/jacoco.exec</destFile>
                    </configuration>
                </execution>
                <execution>
                    <id>post-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <dataFile>${project.test.result.directory}/jacoco/jacoco.exec</dataFile>
                        <outputDirectory>${project.test.result.directory}/jacoco</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
 </build>

```

After I do:

> mvn clean package sonar:sonar -‘Dsonar.host.url’=“[http://dummy.sonar:8080/](http://dummy.sonar:8080/)”

The jacoco files are generated properly: jacoco.xml and jacoco.exec:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/9/9daa62ff7640c1843712c16424644e7cde82f957.png)

But when I check the result in Sonar, the coverage is 0:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/7/7d7c4804aca90a2efffceb43f5db6ff60a8bbeec.png)

This is the console output:

```auto
[INFO] SonarQube version: 7.9.2
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[WARNING] SonarScanner will require Java 11 to run starting in SonarQube 8.x
[INFO] Load global settings
[INFO] Load global settings (done) | time=257ms
[INFO] Server id: ################
[INFO] User cache: ################\.sonar\cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=134ms
[INFO] Load/download plugins (done) | time=168ms
[INFO] Process project properties
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=6ms
[INFO] Project key: test-service
[INFO] Base dir: ############\java\test-service
[INFO] Working dir: ############\java\test-service\target\sonar
[INFO] Load project settings for component key: 'test-service'
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=195ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=1307ms
[INFO] Indexing files...
[INFO] Project configuration:
[INFO] 39 files indexed
[INFO] 0 files ignored because of scm ignore settings
[INFO] Quality profile for java: Sonar way
[INFO] Quality profile for xml: Sonar way
[INFO] ------------- Run sensors on module test-service
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=93ms
[INFO] Sensor JavaSquidSensor [java]
[INFO] Configured Java source version (sonar.java.source): 8
[INFO] JavaClasspath initialization
[INFO] JavaClasspath initialization (done) | time=18ms
[INFO] JavaTestClasspath initialization
[INFO] JavaTestClasspath initialization (done) | time=10ms
[INFO] Java Main Files AST scan
[INFO] 25 source files to be analyzed
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=79ms
[INFO] 25/25 source files have been analyzed
[INFO] Java Main Files AST scan (done) | time=5195ms
[INFO] Java Test Files AST scan
[INFO] 13 source files to be analyzed
[INFO] Java Test Files AST scan (done) | time=1905ms
[INFO] Java Generated Files AST scan
[INFO] 0 source files to be analyzed
[INFO] Java Generated Files AST scan (done) | time=2ms
[INFO] Sensor JavaSquidSensor [java] (done) | time=7357ms
[INFO] Sensor SurefireSensor [java]
[INFO] 13/13 source files have been analyzed
[INFO] 0/0 source files have been analyzed
[INFO] parsing [################\java\test-service\target\test-results\surefire]
[INFO] Sensor SurefireSensor [java] (done) | time=71ms
[INFO] Sensor JavaXmlSensor [java]
[INFO] 1 source files to be analyzed
[INFO] Sensor JavaXmlSensor [java] (done) | time=136ms
[INFO] 1/1 source files have been analyzed
[INFO] Sensor XML Sensor [xml]
[INFO] 1 source files to be analyzed
[INFO] Sensor XML Sensor [xml] (done) | time=122ms
[INFO] 1/1 source files have been analyzed
[INFO] ------------- Run sensors on project
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=41ms
[INFO] Sensor Java CPD Block Indexer
[INFO] Sensor Java CPD Block Indexer (done) | time=63ms
[INFO] SCM provider for this project is: git
[INFO] 39 files to be analyzed
[INFO] 38/39 files analyzed
[WARNING] Missing blame information for the following files:
[WARNING] * pom.xml
[WARNING] This may lead to missing/broken features in SonarQube
[INFO] 8 files had no CPD blocks
[INFO] Calculating CPD for 17 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 195ms, dir size=251 KB
[INFO] Analysis report compressed in 216ms, zip size=113 KB
[INFO] Analysis report uploaded in 493ms
[INFO] ANALYSIS SUCCESSFUL, you can browse ##########################
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at ##########################
[INFO] Analysis total time: 13.672 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:09 min
[INFO] Finished at: 2020-09-28T11:06:21+02:00
[INFO] --------------------------------------------------------

```

I used ### to hide confidential information.

Thank you upfront and best regards,  
Roko

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [September 28, 2020, 3:26pm UTC](https://community.sonarsource.com/t/zero-coverage-sonarqube-even-though-jacoco-generated-all-files/32002/2 "2020-09-28T15:26:15Z")

</div>

Hi Roko,

Welcome to the community!

A couple things strike me here. First, there’s nothing in your log about reading the JaCoCo report. Also, I notice you specify the path to it via a pom property, but that should be picked up automatically (as should projectKey and projectName, for that matter).

I suggest two steps, taken separately. First, on your analysis command line add `-Dsonar.scanner.dumpToFile=[path to file]` (you’ll find the description [here](https://docs.sonarqube.org/7.9/analysis/analysis-parameters/)) to see what property key/value pairs analysis is getting. Second, try commenting out some (most? all?) of those properties & see what happens.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![roko](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@roko](https://community.sonarsource.com/u/roko)\
**Post date:** [September 29, 2020, 8:46am UTC](https://community.sonarsource.com/t/zero-coverage-sonarqube-even-though-jacoco-generated-all-files/32002/3 "2020-09-29T08:46:00Z")

</div>

Hi Ann,

Thank you for the reply. I tried both things:

- When I use `Dsonar.scanner.dumpToFile=[path to file]` , the only jacoco property I see in the dumped file is jacocoArgLine, does this mean that I am missing some sonar-jacoco configuarion?

- When I comment out most of/all of the properties, I can’t see any data on my sonar host url.

Regards,  
Roko

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [September 29, 2020, 7:07pm UTC](https://community.sonarsource.com/t/zero-coverage-sonarqube-even-though-jacoco-generated-all-files/32002/4 "2020-09-29T19:07:24Z")

</div>

Hi Roki,

> [@roko](#):
>
> When I use `Dsonar.scanner.dumpToFile=[path to file]` , the only jacoco property I see in the dumped file is jacocoArgLine, does this mean that I am missing some sonar-jacoco configuarion?

Possibly. Looking at your properties…

```auto
    <sonar.projectKey>test-service</sonar.projectKey>

```

This should be picked up from your pom. No need to include this here

```auto
    <sonar.projectName>test-service</sonar.projectName>

```

ditto

```auto
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>

```

I have super-vague memories that this used to be a thing, but it isn’t any more. You can just drop this.

```auto
    <project.test.result.directory>${project.build.directory}/test-results</project.test.result.directory>

```

Should also be picked up automatically

```auto
    <sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>

```

See `sonar.java.coveragePlugin` above.

```auto

```

I would have expected this to be picked up automatically. I don’t actually see test report generation in your command. Are you sure the reports are generated _before_ analysis?

```auto
    <sonar.language>java</sonar.language>
</properties>

```

This property had been deprecated for years when it was finally decommissioned about a year(?) ago. It’s not doing anything but taking up space. You should just go ahead & delete it.

> [@roko](#):
>
> When I comment out most of/all of the properties, I can’t see any data on my sonar host url.

Wanna share your analysis logs?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [June 22, 2022, 11:30am UTC](https://community.sonarsource.com/t/zero-coverage-sonarqube-even-though-jacoco-generated-all-files/32002/5 "2022-06-22T11:30:32Z")

</div>

A post was split to a new topic: [No project coverage](https://community.sonarsource.com/t/no-project-coverage/66791)
