feat: Add Jacoco coverage and report generation #227
+95
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributor checklist
./gradlew lintKotlin detekt test
command as directed in the testing section of the contributing guideDescription
This change adds the Jacoco plugin to the app/gradle.build.kts file with configuration to generate coverage reports.
Additionally, this adds a step to the unit test Github workflow to use the generated coverage XML to create a comment on PRs. This is not configured to fail the PR build. Details: https://github.com/marketplace/actions/jacoco-report
One thing I wasn't able to configure is coverage verification checks and build time.
I followed details provided in this Medium article on adding coverage to Android projects: https://medium.com/@nachare.reena8/measure-your-codes-reach-integrating-jacoco-code-coverage-in-android-apps-with-kotlin-dsl-382d577864e7
Testing
./gradlew tasks
output:Verified
./gradlew jacocoCoreDebugCodeCoverage
generates files with expected content:The github action/workflow fails to post a comment to the PR when run. I'm not sure what's causing that. I've enabled debug logging on the action/workflow but someone with repo management permissions may need to help me understand what's going wrong with the token permissions.
Related issue