Local Development¶
Integrate Delta Coverage into your daily development workflow for instant feedback on test coverage.
Basic Workflow¶
- Write code
- Write tests
- Run coverage check
- Fix gaps, repeat
Recommended Setup¶
Configure for fast local feedback:
configure<io.github.surpsg.deltacoverage.gradle.DeltaCoverageConfiguration> {
diffSource.git.compareWith("refs/remotes/origin/main")
reports {
console.set(true)
html.set(true)
}
reportViews {
val test by getting {
violationRules.failIfCoverageLessThan(0.8)
}
}
}
Quick Commands¶
Check coverage of current changes¶
Compare with different branch¶
View HTML report¶
./gradlew test deltaCoverage
open build/reports/coverage-reports/delta-coverage/test/html/index.html
Debug configuration issues¶
IDE Integration¶
IntelliJ IDEA¶
Create a run configuration:
- Run → Edit Configurations
- Add New → Gradle
- Tasks:
test deltaCoverage - Name:
Delta Coverage
Now run coverage with a single click.
VS Code¶
Add to .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Delta Coverage",
"type": "shell",
"command": "./gradlew test deltaCoverage",
"group": "test"
}
]
}
Git Hooks¶
Run coverage before pushing:
Make it executable:
Tips¶
Speed Up Feedback¶
Run only unit tests for faster iteration:
Focus on Specific Module¶
Fetch Remote Before Running¶
If comparing with remote branch, fetch first:
View Only Changed Classes¶
The HTML report highlights only changed code. Open it to see exactly which lines need tests.
Troubleshooting¶
Empty Report¶
- Verify you have uncommitted changes or commits not on main
- Run
git diff origin/mainto see what the plugin will analyze - Use
-PexplainOnlyto debug
Wrong Files Analyzed¶
- Check your diff source configuration
- Ensure remote is fetched:
git fetch origin - Verify branch name:
git branch -a
Tests Pass but Coverage Fails¶
The coverage threshold is too high for your current changes. Either:
- Add more tests
- Lower the threshold temporarily
- Use
entityCountThresholdto ignore small changes