Kotlin Objects not getting coverage


(Laszlo Hornyak) #1


I have an open-source kotlin project from github, the CI server is a jenkins running on ubuntu with JDK 8. I have noticed that the project is reporting shamefully low test coverage, apparently because all the kotlin objects report zero test coverage, even though there are tests against these objects. Also the test results appear in the jacoco.xml file.jacoco.xml.txt (2.3 MB)

Github project: https://github.com/kerubistan/kerub
An example object: https://sonarcloud.io/component_measures?id=kerubistan_kerub&metric=coverage&selected=kerubistan_kerub%3Asrc%2Fmain%2Fkotlin%2Fcom%2Fgithub%2Fkerubistan%2Fkerub%2Futils%2Facpi%2FAcpi.kt
And test against the object is here: https://github.com/kerubistan/kerub/blob/master/src/test/kotlin/com/github/kerubistan/kerub/utils/acpi/AcpiTest.kt

Do I need to change something in the settings, or is this not yet covered by SonarCloud?

Best regards,

(Christophe Zurn) #2

Hello Laszlo,

This seems related to this topic.
Basically, JaCoCo currently reports invalid coverage lines for Kotlin in some cases, and the analyzer cannot import coverage information for files impacted by this problem.
If you see in the logs error messages similar to:
Cannot import coverage information for file 'xyz', coverage data is invalid. Error: ..., this means it is indeed related to this issue.
Once this is fixed in JaCoCo, coverage information should then be correct when imported in :sonarcloud:.