JaCoCo & Kotlin: Coverage on Generated Code
JaCoCo works flawlessly with Kotlin. Except when it reports lines not covered on generated code š”. Fortunately thereās a fix already in place.
Update 08/26: JaCoCo 0.8.2 has now officially been released š No need to use the 0.8.2-SNAPSHOT anymore.
What!? I didnāt even write those functions! Thereās no way Iām writing tests for them. Iām pretty sure the compiler knows what itās doingā¦
Good news is that this has been fixed in the latest JaCoCo release (thanks to goodwink). Bad news is that 0.8.2 is not out yet š
If you are like me, and canāt wait to get this working, you can use the SNAPSHOT version of JaCoCo making this changes on your build.gradle
:
1 2 3 4 5 6 7 8 |
|
(Iām using Gradle with Kotlin DSL in this example)
Now you can finally take your Kotlin coverage to 100% without having to write tests for component1()
and component2()
.