FAQ¶
General¶
What is Delta Coverage?¶
Delta Coverage is a tool that computes code coverage for new and modified code based on a git diff. Instead of measuring coverage of the entire codebase, it focuses on what you've changed. It's available as a Gradle plugin and a standalone CLI tool.
Why use Delta Coverage instead of regular coverage?¶
- Actionable feedback — See exactly what you need to test
- Fair metrics — Developers are responsible for their own code, not legacy
- Incremental improvement — Coverage improves naturally as code is modified
- Faster feedback — Focus on relevant changes, not the entire project
Does it replace JaCoCo?¶
No. Delta Coverage uses JaCoCo (or IntelliJ coverage) to collect coverage data. It then filters the data to show only changed code.
When should I use the CLI instead of the Gradle plugin?¶
Use the CLI when:
- You cannot modify the project's build scripts to add the Gradle plugin
- You want to run delta coverage as a separate CI step, decoupled from the build
- Your project uses a build tool other than Gradle (Maven, Bazel, etc.) but produces JaCoCo-compatible coverage data
See the CLI Reference for full details.
Configuration¶
Why isn't the plugin finding my tests?¶
The plugin auto-discovers test tasks. Ensure:
- Your test task extends Gradle's
Testtype - JaCoCo or CoverJet is applied (auto-applied by default)
- Tests produce coverage binary files
Debug with:
How do I compare with a different branch?¶
Or via command line:
CLI
With the CLI, generate the diff externally:
Why is my coverage report empty?¶
Common causes:
- No changes — You have no diff compared to the base branch
- Wrong base branch — Verify you're comparing with the right branch
- Tests didn't run — Run tests before
deltaCoverage - Source paths don't match — Diff file paths must match source directories
Debug:
git diff origin/main --name-only # See what files changed
./gradlew deltaCoverage -PexplainOnly # See what the plugin detected
CLI
For the CLI, ensure --classes and --sources paths match the structure in your diff file. Use --verbose for detailed output.
Can I use Delta Coverage with Kotlin?¶
Yes. For best results with Kotlin, use the IntelliJ coverage engine:
With the CLI: java -jar delta-coverage-cli.jar --engine INTELLIJ ...
Thresholds¶
What's a good coverage threshold?¶
Start with 80% and adjust based on your team:
- 80% — Good starting point for most teams
- 90% — Mature teams with good testing culture
- 70% — Legacy projects or teams new to testing
How do I handle branches that are hard to cover?¶
Use entityCountThreshold to ignore small changes:
rule(CoverageEntity.BRANCH) {
minCoverageRatio.set(0.8)
entityCountThreshold.set(5) // Ignore if < 5 branches
}
Can I have different thresholds for different modules?¶
Yes, use views with class filters:
view("core") {
includeClasses.value(listOf("**/core/**/*.class"))
violationRules.failIfCoverageLessThan(0.95)
}
view("legacy") {
includeClasses.value(listOf("**/legacy/**/*.class"))
violationRules.failIfCoverageLessThan(0.5)
}
CI/CD¶
Why does it fail in CI but pass locally?¶
Common causes:
- Stale coverage data — Run
./gradlew clean test deltaCoverage. Coverage data is appended to existing files, so old data may not reflect current code/test state - Different base branches — CI might compare with
main, local withdevelop - Shallow clone — Ensure
fetch-depth: 0in your checkout action - Stricter thresholds — Check if CI has different configuration
How do I post coverage to PR comments?¶
Use the delta-coverage-action:
- uses: gw-kit/delta-coverage-action@v1
with:
report-path: build/reports/coverage-reports/delta-coverage/test/report.md
Troubleshooting¶
Error: "No coverage data found"¶
- Run tests before
deltaCoverage:./gradlew test deltaCoverage - Verify coverage binary files exist:
find build -name "*.exec" - Check the explain report:
./gradlew deltaCoverage -PexplainOnly
CLI
Verify that --coverage-binary points to existing files. Use glob patterns like 'build/**/jacoco/*.exec' for automatic discovery.
Error: "Cannot compute diff"¶
- Ensure you're in a git repository
- Fetch the remote branch:
git fetch origin main - Verify the branch exists:
git branch -a | grep main
CLI
The CLI reads a diff file directly and does not compute diffs from git. Ensure --diff-file points to a valid unified diff file.
Error: "Plugin must be applied to root project"¶
Move the plugin application to your root build.gradle.kts, not a subproject. This error does not apply to the CLI.
Getting Help¶
- GitHub Issues — Report bugs and request features
- GitHub Discussions — Ask questions