andrey-tech / phpunit-cobertura-comparator-php
A lightweight CLI tool to track PHPUnit code coverage regressions using Cobertura reports
Package info
github.com/andrey-tech/phpunit-cobertura-comparator-php
pkg:composer/andrey-tech/phpunit-cobertura-comparator-php
Requires
- php: ^8.3
- ext-pdo: *
- ext-simplexml: *
- ext-sqlite3: *
- symfony/console: ^5.4 || ^6.4 || ^7.3 || ^8.0
- symfony/yaml: ^5.4 || ^6.4 || ^7.3 || ^8.0
Requires (Dev)
- andrey-tech/pdepend-summary-formatter-php: ^1.3
- overtrue/phplint: ^9.7
- pdepend/pdepend: ^2.16
- phpmd/phpmd: ^2.15
- phpunit/phpunit: ^12.5
- slevomat/coding-standard: ^8.22
- squizlabs/php_codesniffer: ^3.13
- symfony/process: ^5.4 || ^6.4 || ^7.3 || ^8.0
- vimeo/psalm: ^6.16
This package is auto-updated.
Last update: 2026-04-15 06:45:31 UTC
README
PHPUnit Cobertura Comparator is a lightweight CLI tool to track PHPUnit code coverage regressions using Cobertura reports.
Installation
The tool requires PHP version 8.3 or higher.
Install via Composer:
composer require --dev andrey-tech/phpunit-cobertura-comparator-php
Usage
The command line:
./vendor/bin/phpunit-cobertura-comparator <old Cobertura XML file> <new Cobertura XML file>
The optional command line arguments:
--no-colors— disable ANSI color output;--ignore-branch-rate— ignore branch-rate in a Cobertura XML file.
An example command line:
./vendor/bin/phpunit-cobertura-comparator cobertura-old.xml cobertura-new.xml
An example of the console output:
Parsing Cobertura XML file 'cobertura-old.xml'...
Parsing Cobertura XML file 'cobertura-new.xml'...
Coverage comparison: 2025-09-02T11:27:55+00:00 -> 2025-09-03T06:54:35+00:00
Coverage regressions found in 1 class(es):
CLASS: App\Purchase\Fixer
+---------------------------+--------+------------------+--------------------+
| Method | Status | Line coverage, % | Branch coverage, % |
+---------------------------+--------+------------------+--------------------+
| CLASS | old | 98.44 -> 92.58 | 92.53 -> 85.22 |
| fix | old | 100.00 -> 100.00 | 100.00 -> 100.00 |
| fixPrice | old | 96.11 -> 100.00 | 94.76 -> 75.33 |
| fixRate | new | x -> 85.90 | x -> 95.24 |
| fixCharges | del | 100.00 -> x | 100.00 -> x |
+---------------------------+--------+------------------+--------------------+
Exit code: 2. Time: 6 ms. Memory: 1.40/2.00 MiB.
Columns in the table:
Method— the method name;Status— the status of the method or class (old,new,del);Line coverage, %— the line coverage of the method or class (old->new);Branch coverage, %— the branch coverage of the method or class (old->new).
The tool shows line and branch coverage, measured by PHP Unit, in ANSI colors:
| Color | Line or branch coverage | Status |
|---|---|---|
red |
The coverage has decreased | — |
yellow |
— | Deleted |
green |
The coverage has increased | New |
white |
The coverage has not changed | Old |
Exit codes
The tool defines different exit codes:
| Code | Description |
|---|---|
| 0 | Everything worked as expected and no coverage regressions found |
| 1 | An error/exception occurred which has interrupted tool during execution |
| 2 | Everything worked as expected but coverage regressions found |
Authors and Maintainers
The author and maintainer of PHPUnit Cobertura Comparator is andrey-tech.
License
This tool is licensed under the MIT license.
