Search by

andrey-tech / phpunit-cobertura-comparator-php

andrey-tech

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

Statistics

Installs: 881

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.2.1 2026-04-15 06:31 UTC

This package is auto-updated.

Last update: 2026-09-15 07:40:43 UTC


README

PHPUnit Cobertura Comparator logo

Latest Stable Version PHP workflow Total Downloads PHP Version Require License

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.