Global coverage counts every line any test touched. Parity checks that each source file is exercised by its own test, and fails CI when a different test is doing the work.
Reads PHPUnit, Clover, Cobertura, and Parity JSON coverage from PHP, JavaScript, TypeScript, and Rust projects.
final class Calculator{ public function add(int $left, int $right): int { return $left + $right; } public function subtract(int $left, int $right): int { return $left - $right; } public function multiply(int $left, int $right): int { return $left * $right; } public function divide(int $left, int $right): int { return intdiv($left, $right); } public function maximum(int $left, int $right): int { return max($left, $right); }} Each sample passes an 80% global coverage gate. In each one, a single file gets most of its coverage from a test that belongs to something else. These numbers come from each repository's CI run of parity test.
src/Calculator.php80% overall, but only 40%from its own testapp/Services/InvoiceTotal.php80% overall, but only 40%from its own testsrc/InvoiceCalculator.php80% overall, but only 40%from its own testsrc/Slugger.php80% overall, but only 40%from its own testsrc/sum.js85.71% overall, but only 42.86%from its own testsrc/greeting.js85.71% overall, but only 42.86%from its own testsrc/formatCurrency.ts100% overall, but only 50%from its own testsrc/formatCurrency.ts80% overall, but only 44%from its own testapp/services/user_presenter.ts84% overall, but only 44%from its own testsrc/lib.rs80% overall, but only 40%from its own testsrc/lib.rs80% overall, but only 40%from its own testKeep your test runner and your coverage tool. Parity reads what they already produce.
parity init writes a parity.yaml. Each structure says where a file's own test lives and how much of the file it must cover.
structure:
- name: "Currency"
paths:
source: "code/src"
test: "code/tests"
rules:
- minimum-coverage:
min: 70
- matched-coverage:
min: 70If your coverage tool already records which test hit which line, skip this. Otherwise parity test runs every test file in isolation and keeps one report per test.
$ parity test --format=jsonThe suite reaches 100%, but formatCurrency.test.ts covers only half of its own file, so the check fails and says which file to fix.
formatCurrency.ts
Cov 100%
Match 50% N
Global 100.00% OK
Per-file min
(matching test only) 50.00% FAILcomposer global require testparity/parityRequires PHP 8.4 or newer, even for JavaScript and Rust projects. A standalone PHAR is attached to every GitHub release. Parity is MIT licensed.