PHPackages                             thor-juhasz/phpunit-coverage-check - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. thor-juhasz/phpunit-coverage-check

ActiveLibrary[Testing &amp; Quality](/categories/testing)

thor-juhasz/phpunit-coverage-check
==================================

A PHPUnit test coverage checker

v0.3.0(4y ago)1874.7k—1.2%11MITPHPPHP &gt;=7.4

Since Jul 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/thor-juhasz/phpunit-coverage-check)[ Packagist](https://packagist.org/packages/thor-juhasz/phpunit-coverage-check)[ RSS](/packages/thor-juhasz-phpunit-coverage-check/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (1)

phpunit-coverage-check
======================

[](#phpunit-coverage-check)

[![CI workflow](https://github.com/thor-juhasz/phpunit-coverage-check/actions/workflows/ci.yaml/badge.svg)](https://github.com/thor-juhasz/phpunit-coverage-check/actions)[![Coverage Status](https://camo.githubusercontent.com/114b2409e51634357a1523f02f795b1240a1bc8de4984d974dd6fa3374c9fde6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f74686f722d6a756861737a2f706870756e69742d636f7665726167652d636865636b2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/thor-juhasz/phpunit-coverage-check?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7cc9e1f1bf13db162ec6ac9defb969bf7f9459803a6a2bbaa3337de325ea2cb6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74686f722d6a756861737a2f706870756e69742d636f7665726167652d636865636b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thor-juhasz/phpunit-coverage-check/?branch=master)[![Build Status](https://camo.githubusercontent.com/d0ce095e9bd7dec53e7b31aae757c363bd6f9b35da2b61b2e7fd53947f2c47c0/68747470733a2f2f7777772e7472617669732d63692e636f6d2f74686f722d6a756861737a2f706870756e69742d636f7665726167652d636865636b2e7376673f6272616e63683d6d6173746572)](https://www.travis-ci.com/thor-juhasz/phpunit-coverage-check)

[![GitHub license](https://camo.githubusercontent.com/478d32d2e7019a5a2dfe71e6d70afd47247943d4038157a751a4da820008e434/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f74686f722d6a756861737a2f706870756e69742d636f7665726167652d636865636b2e737667)](https://github.com/thor-juhasz/phpunit-coverage-check/blob/master/LICENSE)[![GitHub release](https://camo.githubusercontent.com/2aba7e7055a176c576aa8fb8f3593719f052e5e3019e230b7366f189a853cdb7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f74686f722d6a756861737a2f706870756e69742d636f7665726167652d636865636b2e737667)](https://github.com/thor-juhasz/phpunit-coverage-check/releases/)

A PHPUnit test coverage checker.

This command will parse a clover.xml report file (generated by PHPUnit), to check that the test coverage meets a certain threshold (80% by default).

This library is loosely based on [johanvanhelden's test coverage check](https://github.com/johanvanhelden/gha-clover-test-coverage-check).

Table of contentsTable of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Use in GitHub workflow](#use-in-github-workflow)
    - [Run manually](#run-manually)
- [Arguments](#arguments)
    - [filename](#filename-required)
- [Options](#options)
    - [threshold](#threshold-optional)
    - [metric](#metric-optional)
    - [suppress-errors](#suppress-errors-optional)
- [Output](#output)

Installation
------------

[](#installation)

Run this in your projects root directory:

```
composer require --dev thor-juhasz/phpunit-coverage-check
```

This will add a new PHP binary to your `vendor/bin/` directory, named `phpunit-coverage-check`.

Usage
-----

[](#usage)

### Use in GitHub workflow

[](#use-in-github-workflow)

To use this library in a GitHub CI workflow, make sure to generate a `clover.xml` report file when running phpunit:

```
      - name: Run PHPUnit Tests
        run: ./vendor/bin/phpunit --coverage-clover clover.xml
```

Then simply add this after the step than runs phpunit:

```
      - name: Test coverage
        run: ./vendor/bin/phpunit-coverage-check -t 100 clover.xml
```

### Run manually

[](#run-manually)

Generate a `clover.xml` report file with PHPUnit:

```
./vendor/bin/phpunit --coverage-clover clover.xml
```

Then you can run the binary provided by this library, passing the name of the clover.xml file as the first argument:

```
./vendor/bin/phpunit-coverage-check clover.xml
```

Arguments
---------

[](#arguments)

### filename (required)

[](#filename-required)

The filename of the clover coverage XML file.

Example:

```
./vendor/bin/phpunit-coverage-check clover.xml
```

Options
-------

[](#options)

### threshold (optional)

[](#threshold-optional)

Default value: 80

The threshold determines the lower value of acceptable test coverage. You can pass your desired threshold using `--threshold N` or `-t N` for short, where `N` is a number ranging from 0 to 100:

Example:

```
# Requires 100% coverage
./vendor/bin/phpunit-coverage-check --threshold 100 clover.xml
# Requires 50% coverage
./vendor/bin/phpunit-coverage-check -t 50 clover.xml
# By default when passing no threshold option, it will require 80% coverage
./vendor/bin/phpunit-coverage-check clover.xml
```

### metric (optional)

[](#metric-optional)

Default value: elements

You can specify here which metric you want to use to read the code coverage. The supported metrics are:

- elements
- statements
- methods

Example:

```
./vendor/bin/phpunit-coverage-check --metric statements clover.xml
./vendor/bin/phpunit-coverage-check -m methods clover.xml
# By default when passing no metric option, it will use elements
./vendor/bin/phpunit-coverage-check clover.xml
```

### suppress-errors (optional)

[](#suppress-errors-optional)

When the code coverage reported in the clover XML report is under the specified threshold, the command will exit with code 1. When used in a CI workflow, this results in that job failing.

If you would like to use this tool in a CI workflow, without failing the job, you can pass the `--suppress-errors`option (or `-s` for short).

Example:

```
      # Even if the coverage is under the threshold, this will not fail the job
      - name: Test coverage
        run: ./vendor/bin/phpunit-coverage-check -t 100 clover.xml
```

Output
------

[](#output)

Example outputs:

```
# When coverage is 100%, and default threshold used.
$ ./vendor/bin/phpunit-clover-test-coverage-check clover.xml
[OK] Code coverage is 100%, which is acceptable (requires >= 80% coverage)

# When coverage is 100%, and threshold is set to 100%.
$ ./vendor/bin/phpunit-clover-test-coverage-check clover.xml
[OK] Code coverage is 100%, which is acceptable (requires full coverage)

# When coverage is 1%, and default threshold used.
$ ./src/test-coverage-checker.php clover.xml
[ERROR] Code coverage is 1%, which is not acceptable (requires >= 80% coverage)

# When coverage is 1%, and threshold is set to 100%.
$ ./src/test-coverage-checker.php clover.xml
[ERROR] Code coverage is 1%, which is not acceptable (requires full coverage)
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

1779d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc33aab1d9f011935cd29ef6c2ad8eb938d3f725146a7cccdb8588e82e73ce55?d=identicon)[thor-juhasz](/maintainers/thor-juhasz)

---

Top Contributors

[![thor-juhasz](https://avatars.githubusercontent.com/u/43342865?v=4)](https://github.com/thor-juhasz "thor-juhasz (31 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thor-juhasz-phpunit-coverage-check/health.svg)

```
[![Health](https://phpackages.com/badges/thor-juhasz-phpunit-coverage-check/health.svg)](https://phpackages.com/packages/thor-juhasz-phpunit-coverage-check)
```

###  Alternatives

[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
