https://kotlinlang.org logo
Title
a

Ali Kabiri

03/28/2023, 11:32 AM
How can Kotlin operator functions be covered in test reports? Since
kotlinx-kover
does not support instrumentation tests executed on Android device, I am still using a Jacoco gradle task for generating code coverages. In this case,
operator fun
's signature is marked uncovered by Jacoco, although the method body is being covered (see screenshot)! How can I cover the method signature? Would there be any workaround to cover it?
m

marlonlom

03/28/2023, 3:49 PM
Did you add unit tests for the suspend function? afaik, when running the jacoco report, it takes the coverage for unit tests and not for the instrumented ones
a

Ali Kabiri

03/28/2023, 3:51 PM
c

chanjungskim

03/29/2023, 6:50 AM
I guess coverage is just for unit test?
a

Ali Kabiri

03/29/2023, 9:12 AM
@chanjungskim Good point, but that doesn't seem to be the case, since the existing coverage is also coming from instrumented tests. If it helps, feel free to view/clone the project here: https://github.com/trustedshops-public/etrusted-android-trustbadge-library You can run all the tests with coverage from commandline using:
bundle exec fastlane test
The HTML coverage file will be under following path:
library/build/mergedReportDir/jacocoTestReport/html/index.html
n

Nino

03/30/2023, 3:16 PM
Problems are: • Jacoco doesn't understand Kotlin magic, giving an incorrect coverage for Kotlin classes • Kover does understand Kotlin magic, giving a correct coverage for Kotlin classes and • Jacoco can parse Android execution tests ("end to end" / "ui" / Espresso/Barista/younameit tests) • Kover cannot (yet ! it's their target for 1.0 release) parse Android execution tests.
a

Ali Kabiri

04/03/2023, 10:21 AM
Thank you so much for clarifying the problem :) I wish there could also be a workaround for it. 🙂