rregeer/phpunit-coverage-check
phpunit.xml) and its reliance on test-driven development make this package a natural fit for enforcing coverage standards. It complements Laravel’s testing ecosystem without requiring architectural changes.--coverage-clover (already common in Laravel projects).80) or parameterized (e.g., via CI environment variables) for dynamic enforcement.phpunit.xml config?main branch, allow lower thresholds for PRs)steps with run commands.before_script or test job.- name: Check coverage
run: vendor/bin/coverage-check clover.xml 80
main to pass with lower thresholds (e.g., 70%).main if coverage drops below target.phpunit.xml includes:
<coverage>
<include>...</include>
<exclude>...</exclude>
<clover>clover.xml</clover>
</coverage>
clover.xml is generated before running the check.phpunit --coverage-clover clover.xml
vendor/bin/coverage-check clover.xml 80
0 = pass, 1 = fail) in CI to:
CONTRIBUTING.md or CODE_OF_CONDUCT.$COVERAGE_THRESHOLD) for dynamic values.- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: clover.xml
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Missing clover.xml | CI job fails | Add validation step before coverage check. |
| Threshold too high | Blocks merges unnecessarily | Start with conservative thresholds (e.g., 70%). |
| PHPUnit clover.xml format change | Package breaks | Fork and maintain or switch to alternative. |
| CI flakiness (race conditions) | Inconsistent failures | Cache clover.xml or retry failed checks. |
tests/ from coverage).How can I help you explore Laravel packages today?