xmarcusv
xmarcusv

Reputation: 63

SonarQube + Jacoco - Unable to read Koin module test coverage

I'm having some issues when trying to import Jacoco code coverage to sonar, this is happening to all Koin modules.

Sonar version: 7.5.0.20127

Jacoco version: 0.8.2

Erro:

       ERROR: Cannot import coverage information for file 'mmaccount/src/main/java/br/com/project/mmaccount/di/AccountModule.kt', coverage data is invalid. Error: {}
java.lang.IllegalStateException: Line 84 is out of range in the file mmaccount/src/main/java/br/com/project/mmaccount/di/AccountModule.kt (lines: 83)
    at org.sonar.api.internal.google.common.base.Preconditions.checkState(Preconditions.java:197)
    at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:93)
    at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.lineHits(DefaultCoverage.java:81)

And because of this, my module class is with 0% of o coverage, but if I look the HTML report it seems to work fine:

Jacoco HTML report

This is happening only with my Koin modules, I'm not sure if the problem is how Koin works or some incompatibility between Jacoco and Kotlin

Upvotes: 3

Views: 1489

Answers (1)

Denisse Suarez
Denisse Suarez

Reputation: 91

I had the same problem, it seem it was an issue of jacoco when generating the report, more info on this issue: https://github.com/jacoco/jacoco/issues/763

The solution: upgrade to 0.8.3 that was release with that issue fixed.

With the new version of jacoco now my classes that had zero coverage on sonar now have the real coverage.

Upvotes: 5

Related Questions