How can Kotlin operator functions be covered in te...
# android
a
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
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
c
I guess coverage is just for unit test?
☝️ 1
a
@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:
Copy code
bundle exec fastlane test
The HTML coverage file will be under following path:
Copy code
library/build/mergedReportDir/jacocoTestReport/html/index.html
1
n
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.
👍 1
a
Thank you so much for clarifying the problem :) I wish there could also be a workaround for it. 🙂