teqnomaze / code-coverage
Check for the code coverage using the clover report of phpunit.
2.0.0
2026-10-25 17:49 UTC
Requires
- php: >=8.2
Requires (Dev)
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^11
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A command-line tool that checks the code coverage percentage in PHPUnit's clover.xml report against a minimum threshold, and fails the build when coverage is too low.
Requirements
- PHP 8.2 or higher
- Composer 2.x
- A PHPUnit
clover.xmlreport (generated with--coverage-clover)
Installation
Require the package as a development dependency in your project:
composer require --dev teqnomaze/code-coverage
Usage
vendor/bin/code-coverage <clover.xml> [threshold]
| Argument | Description | Default |
|---|---|---|
clover.xml |
Path to the clover.xml file generated by PHPUnit. |
Required |
threshold |
Minimum acceptable coverage percentage, from 1 to 100. | 80 |
Example:
vendor/bin/phpunit --coverage-clover build/clover.xml vendor/bin/code-coverage build/clover.xml 90
Output:
Code coverage is 94%, which is above the accepted 90%
The displayed percentage is rounded down, while the pass or fail decision uses the exact value.
Exit codes
| Code | Meaning |
|---|---|
0 |
Coverage meets or exceeds the threshold. |
1 |
Coverage is below the threshold. |
2 |
Usage error, missing or invalid file, or invalid threshold. |
Changelog
All notable changes to this project are documented in CHANGELOG.md.
License
This project is licensed under the MIT License. See LICENSE.md for more information.