Skip to content

Enable JaCoCo test coverage for debug builds#2284

Open
timothyfroehlich wants to merge 8 commits intomainfrom
wb/froeht/basic-jacoco-config
Open

Enable JaCoCo test coverage for debug builds#2284
timothyfroehlich wants to merge 8 commits intomainfrom
wb/froeht/basic-jacoco-config

Conversation

@timothyfroehlich
Copy link
Copy Markdown
Member

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.

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.
Copilot AI review requested due to automatic review settings August 13, 2025 20:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*"
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"**/*Test*.*"
"**/*Test.class",
"**/*Tests.class"

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 28.46%. Comparing base (38e2647) to head (f33239d).
⚠️ Report is 45 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (38e2647) and HEAD (f33239d). Click for more details.

HEAD has 16 uploads less than BASE
Flag BASE (38e2647) HEAD (f33239d)
rust 9 1
kotlin 9 1
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     
Flag Coverage Δ
kotlin 27.18% <ø> (-45.72%) ⬇️
rust 30.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 13, 2025

Snapshot diff report vs base branch: main
Last updated: Tue Oct 14 08:38:24 PDT 2025, Sha: f33239d
No differences detected

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.
@timothyfroehlich timothyfroehlich force-pushed the wb/froeht/basic-jacoco-config branch from 73f6dae to 3ede023 Compare August 14, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants