Skip to content

[test-improver] Add JaCoCo code coverage reportingΒ #47

Description

@github-actions

πŸ€– Test Improver β€” automated AI assistant focused on improving test infrastructure.

Implements the requirements from Issue #26.

Goal & Rationale

No coverage tooling was configured, giving maintainers zero visibility into which code paths are actually tested. This PR adds JaCoCo so every CI run produces an HTML/XML/CSV coverage report that can be downloaded as an artifact.

Changes

pom.xml β€” adds jacoco-maven-plugin 0.8.11 with two executions:

  • prepare-agent (default initialize phase): instruments bytecode before Surefire runs tests
  • report (bound to verify phase): generates HTML, XML, and CSV reports under target/site/jacoco/

.github/workflows/ci.yml β€” adds two steps after Run Tests:

  1. Generate coverage report β€” runs mvn jacoco:report -B with if: always() so the report is generated even when pre-existing test failures exit non-zero
  2. Upload coverage report β€” uploads target/site/jacoco/ as a CI artifact (coverage-report, 30-day retention)

Baseline Coverage (from this PR branch)

Metric Covered Total %
Instructions 1 930 4 553 42%
Branches 141 397 35%
Lines 400 1 001 39%

Note: ~12% of instruction coverage comes from DataInitializer executing during @SpringBootTest setup β€” not from dedicated tests. Effective "intentional" coverage is lower. This is why Issue #20 (meaningful coverage) is the next priority.

Notable gaps visible in the report:

  • Controllers: ~1% β€” only the Spring MVC setup path is hit, no endpoint tests
  • UserService: ~1% β€” zero unit tests
  • NotificationService: ~11% β€” very limited coverage

Trade-offs

Test Status

Tests run: 38, Failures: 1, Errors: 1, Skipped: 7

Pre-existing failures (not caused by this PR):

Coverage report generates successfully with if: always() even when tests fail.

Reproducibility

mvn test -B
mvn jacoco:report -B
# open target/site/jacoco/index.html

Warning

Protected Files β€” Push Permission Denied

This was originally intended as a pull request, but the patch modifies protected files. A human must create the pull request manually.

Protected files
  • pom.xml

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the patch from the workflow run
gh run download 28671834478 -n agent -D /tmp/agent-28671834478

# Create a new branch
git checkout -b test-assist/jacoco-coverage-setup-e48ff900304a51de main

# Apply the patch (--3way handles cross-repo patches)
git am --3way /tmp/agent-28671834478/aw-test-assist-jacoco-coverage-setup.patch

# Push the branch and create the pull request
git push origin test-assist/jacoco-coverage-setup-e48ff900304a51de
gh pr create --title '[test-improver] Add JaCoCo code coverage reporting' --base main --head test-assist/jacoco-coverage-setup-e48ff900304a51de --repo Study4/agentic-workflow-demo

Generated by Test Improver Β· 102.9 AIC Β· βŒ– 10.7 AIC Β· ⊞ 10.9K Β· β—·
Comment /test-assist to run again

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/test-improver.md@1c6668b751c51af8571f01204ceffb19362e0f66

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions