mannodermaus / android-junit5

Testing with JUnit 5 for Android.
Apache License 2.0
873 stars 52 forks source link

Jacoco code coverage for androidTest #359

Open F43nd1r opened 3 weeks ago

F43nd1r commented 3 weeks ago

Hey @mannodermaus, I'm trying to create a jacoco report for instrumented junit 5 tests. With applying the jacoco plugin and enableAndroidTestCoverage = true I can get a report with all classes, but it always reports zero coverage.

Is this supported? If so, how can I configure this correctly?

mannodermaus commented 3 weeks ago

I don't have a lot of first-hand experience with Jacoco myself, but certainly there have been many instances in the past where its reporting didn't want to pick up the coverage files properly. The naming of enableAndroidTestCoverage tells me that you want to observe coverage from your instrumentation tests? So far we've only ever dealt with unit tests for this, so it's not unlikely that there are some file paths that aren't correctly reported to Jacoco. Could you share the versions of AGP and android-junit5 that you're employing in your project?

F43nd1r commented 3 weeks ago

Yes, this is about instrumented tests. AGP 8.5.2 and android-junit5 1.11.2.0 (with compose extension 1.6.0)

mannodermaus commented 2 weeks ago

Thanks! No promises I can look at this quickly, but I'll keep this open and will try to take a look at it. 🙇‍♂️