Download the PHP package thor-juhasz/phpunit-coverage-check without Composer
On this page you can find all versions of the php package thor-juhasz/phpunit-coverage-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thor-juhasz/phpunit-coverage-check
More information about thor-juhasz/phpunit-coverage-check
Files in thor-juhasz/phpunit-coverage-check
Package phpunit-coverage-check
Short Description A PHPUnit test coverage checker
License MIT
Informations about the package phpunit-coverage-check
phpunit-coverage-check
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.
Table 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
Run this in your projects root directory:
This will add a new PHP binary to your vendor/bin/
directory, named phpunit-coverage-check
.
Usage
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:
Then simply add this after the step than runs phpunit:
Run manually
Generate a clover.xml
report file with PHPUnit:
Then you can run the binary provided by this library, passing the name of the clover.xml file as the first argument:
Arguments
filename (required)
The filename of the clover coverage XML file.
Example:
Options
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:
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:
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:
Output
Example outputs:
All versions of phpunit-coverage-check with dependencies
ext-bcmath Version *
ext-simplexml Version *
symfony/console Version 4.*|5.*