Coverage Commands ​
The Coverage command group wraps the CoverageService / Coverage facade to analyse Clover XML reports, generate reports, check PR thresholds, watch live coverage changes, and AI-generate missing tests.
| Command | Description |
|---|---|
| coverage:analyze | Analyse a Clover XML report and display per-file coverage |
| coverage:pr:check | Compare coverage against a base branch and fail if below threshold |
| coverage:report | Generate JSON, Markdown, or HTML coverage reports |
| coverage:generate-tests | Scaffold missing tests — optionally via AI provider |
| coverage:watch | Poll a Clover file and display diffs as coverage changes |
Prerequisites ​
All commands require a Clover XML file produced by PHPUnit or Pest:
bash
php artisan test --coverage-clover=storage/app/clover.xmlThe default file name and directory can be overridden per command with --cloverName and --cloverDir.
Common Workflows ​
Generate a local coverage report ​
bash
php artisan test --coverage-clover=storage/app/clover.xml
php artisan modularous:coverage:analyze # quick per-file summary
php artisan modularous:coverage:report # JSON / markdown / HTML renderingGate a pull request on coverage ​
bash
php artisan modularous:coverage:pr:check --threshold=80 --base=mainFails with a non-zero exit code when PR coverage drops below the threshold — wire it into CI.
Scaffold missing tests (optionally AI-assisted) ​
bash
php artisan modularous:coverage:generate-testsCreates PHPUnit/Pest test stubs for uncovered methods. When an AI provider is configured, --ai fills in assertions; otherwise the stubs are empty scaffolds.
Watch coverage during TDD ​
bash
php artisan modularous:coverage:watchPolls the Clover file and prints a diff whenever coverage changes — run alongside your test runner for fast feedback.
Related ​
- CoverageService — underlying service
- Coverage facade — programmatic access