Enable JaCoCo test coverage for debug builds#2284
Enable JaCoCo test coverage for debug builds#2284timothyfroehlich wants to merge 8 commits intomainfrom
Conversation
This change configures JaCoCo to generate unit test coverage reports for the debug build type. It also sets up exclusions for certain classes and configures the JaCoCo report task to specify source directories, class directories, and execution data.
There was a problem hiding this comment.
Pull Request Overview
This change integrates JaCoCo test coverage reporting into the Android module by configuring it for debug builds and creating a custom test report task. The implementation follows established patterns for Android projects with Kotlin DSL.
- Enables unit test coverage for debug builds in the Android configuration
- Sets up JaCoCo exclusions for common Android-generated classes and internal JDK classes
- Creates a custom JaCoCo report task that specifies source directories, class directories, and execution data paths
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
designcompose/build.gradle.kts
Outdated
| "**/R$*.class", | ||
| "**/BuildConfig.*", | ||
| "**/Manifest*.*", | ||
| "**/*Test*.*" |
There was a problem hiding this comment.
The exclusion pattern **/*Test*.* is too broad and may exclude legitimate production classes that contain 'Test' in their name (e.g., TestUtils, TestData model classes). Consider using more specific patterns like **/*Test.class and **/*Tests.class to target actual test classes.
| "**/*Test*.*" | |
| "**/*Test.class", | |
| "**/*Tests.class" |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #2284 +/- ##
============================================
- Coverage 34.37% 28.46% -5.92%
- Complexity 19 77 +58
============================================
Files 38 75 +37
Lines 4177 10304 +6127
Branches 49 1324 +1275
============================================
+ Hits 1436 2933 +1497
- Misses 2728 6988 +4260
- Partials 13 383 +370
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Snapshot diff report vs base branch: main |
I'm currently focused on crafting a precise commit message. I'm removing the `jacocoTestReport` task, which was aggregating test reports from various subprojects like annotation, common, and designcompose within the build.gradle.kts file. Also, I am making some updates to the main.yml GitHub workflow file. **Clarifying JaCoCo Integration** I've distilled the changes: the core is a simplification of JaCoCo reporting. The main shift involves eliminating the custom aggregation task in `build.gradle.kts`, which formerly covered multiple modules. This setup is now replaced by relying solely on the `designcompose` module's report, necessitating adjustments in the GitHub workflow to reflect this shift. I must emphasize this module-specific change in the commit message. **Constructing the Commit Message** My current focus is crafting the commit message. I've decided to focus on the main points: the custom aggregation task is gone, and the workflow now relies solely on the `designcompose` module's JaCoCo report. I'm aiming for brevity while ensuring clarity about the shift in coverage scope and simplified build setup. **Composing the Commit Message** I'm refining the commit message. I'm considering a short title, like "Simplify JaCoCo Reporting," and then a concise body. I will emphasize the removal of the aggregated task and the shift to using the `designcompose` module's report within the CI workflow. **Finalizing the Commit Message** I've decided on the commit message: "Remove aggregated JaCoCo report task." The body will explain that the custom `jacocoTestReport` task is gone for build simplification and the CI uses the `designcompose` module's report. I believe this title is direct, and the body clearly explains the changes. It's concise and focuses on the core modification. Remove aggregated JaCoCo report task The custom `jacocoTestReport` task at the root level has been removed to simplify the build configuration. The CI workflow is updated to use the JaCoCo report generated by the `designcompose` module instead.
73f6dae to
3ede023
Compare
This change configures JaCoCo to generate unit test coverage reports for the debug build type. It also sets up exclusions for certain classes and configures the JaCoCo report task to specify source directories, class directories, and execution data.
Much of this has been copied from https://medium.com/make-android/measure-your-codes-reach-integrating-jacoco-code-coverage-in-android-apps-with-kotlin-dsl-382d577864e7
Asking Gemini to "find me examples of a working and minimal jacoco setup in an android gradle project using kotlin script" produced a similar result, but did miss the classDirectories.