https://kotlinlang.org logo
Title
k

kschlesselmann

11/22/2018, 1:11 PM
Does anyone know if there's a solution to kotlin + JaCoCo? I cannot meet my quality gates in sonar because coverage is too low. There are a couple of functions that should be covered though
c

christophsturm

11/22/2018, 1:24 PM
I’m using jacoco 0.8.2 and that works fine with kotlin
k

kschlesselmann

11/22/2018, 1:26 PM
I end up with
Cannot import coverage information for file …, coverage data is invalid. Error: {}
java.lang.IllegalStateException: Line 13 is out of range in the file … (lines: 12)
Current gradle + jacoco plugin (I think it's version 0.8.2 as well)
Maybe it's a problem of the sonarqube import?
c

christophsturm

11/22/2018, 1:29 PM
thats probably it, because normal jacoco works for me
m

Melvin Biamont

11/22/2018, 1:57 PM
@christophsturm Even with Jacoco 0.8.2 I still have issues with Kotlin. It ask me to test my data classes, exceptions or
GlobalScope.launch{
lines. Do you have any solutions for that ?
m

Mike

11/22/2018, 2:06 PM
I exclude them from coverage and sonar, but that may not be an option for you. There are some Kotlin conventions that Jacoco just doesn’t determine coverage correctly for. inline functions are a great example of that.
m

Melvin Biamont

11/22/2018, 2:08 PM
How do you exclude them ? Sonar allows only to exclude files using file name pattern, but I can’t exclude all my data class 1 by 1. Isn’t there any other solution?
m

Mike

11/22/2018, 3:13 PM
Sonar supports wildcard exclusions too so assuming they're all in one package...