Download the PHP package esi/phpunit-coverage-check without Composer
On this page you can find all versions of the php package esi/phpunit-coverage-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download esi/phpunit-coverage-check
More information about esi/phpunit-coverage-check
Files in esi/phpunit-coverage-check
Package phpunit-coverage-check
Short Description Check the code coverage using the clover report of PHPUnit.
License MIT
Informations about the package phpunit-coverage-check
PHPUnit Coverage Check
PHPUnit Coverage Check - Check the code coverage using the clover report of PHPUnit.
This php script will read the clover xml report from PHPUnit and calculate the coverage score. Based on the given threshold the script will exit ok if the coverage is higher than the threshold or exit with code 1 if the coverage is lower than the threshold.
This script can be used in your continuous deployment environment or for example added to a pre-commit hook.
GitHub Action
A GitHub action has been created for this library and can be found in the PHPUnit Coverage Check Action repository, or on the GitHub Marketplace.
Acknowledgements/Credits
This library is a fork of/based upon rregeer/phpunit-coverage-check by Richard Regeer.
Most of this library has been rewritten from the ground up, to replace and improve a majority of the original library. The overall idea, and key pieces of the calculation, are thanks to the original library. Many thanks and much appreciation to Richard Regeer for his wonderful work.
Please see LICENSE file for more information.
For more information on changes made in this library, in comparison to the original by Richard Regeer, please see the CHANGELOG file.
Phar generation is handled by using Box. My implementation of the coverage:check
command, with Symfony\Console, was inspired by SensioLabs Security Checker.
Important Note
This project is not in any way an official PHPUnit
project. Meaning, that it is not associated with, or endorsed by, the PHPUnit
project or its author Sebastian Bergmann
.
Installation
Composer
The script can be installed using composer. Add this repository as a dependency to the composer.json file.
To use PHPUnit Coverage Check on PHP 8.1, use version 1.0.0 (and check 1.x's readme as usage is slightly different):
Phar
Download the phpunit-coverage-check.phar
from an available release. It is recommended to check the signature when downloading the Phar from a GitHub Release (with phpunit-coverage-check.phar.asc
).
The Phar files of PHPUnit Coverage Check are signed with a public key associated to [email protected].
.
The key(s) associated with this E-Mail address
can be queried at keys.openpgp.org
.
Install with Phive
You can also install the PHPUnit Coverage Check Phar with Phive
.
If not already using Phive, you can read more about it here, also Phive installation and usage.
Usage
The script has 2 parameters that are mandatory to return the code coverage.
- The location of the clover xml file, that's generated by PHPUnit.
- The coverage threshold that is acceptable. Min = 1, Max = 100
Generate the clover.xml
file by using PHPUnit:
It's also possible to add the coverage report generation to your PHPUnit configuration file (phpunit.xml.dist
for example). You would add to following lines to the xml file inside the <coverage>
tag:
- For more information see the PHPUnit Documentation.
- Information about the configuration file and commandline options.
If installed with Composer
You can also use the Api directly if you wish. I created a function called nonConsoleCall
that will process and return the data, similar to how the console application displays it.
An example usage:
If using the Phar
With --only-percentage
(or -O
) enabled, the CLI command will only return the resulting coverage percentage.
--show-files
With --show-files
(or -F
), --only-percentage
will be ignored. This option parses the clover file for coverage information for each file in the project/package, determine coverage, and display the information in a table. For example:
Passing coverage
Mixed pass/fail coverage
About
Requirements
- PHPUnit Coverage Check works with PHP 8.2.0 or above.
Submitting bugs and feature requests
Bugs and feature requests are tracked on GitHub
Issues are the quickest way to report a bug. If you find a bug or documentation error, please check the following first:
- That there is not an Issue already open concerning the bug
- That the issue has not already been addressed (within closed Issues, for example)
Contributing
See CONTRIBUTING
Backward Compatibility Promise
- See backward-compatibility.md
Credits
- Author: Eric Sizemore
- Thanks to all Contributors.
- Special thanks to JetBrains for their Licenses for Open Source Development.
Author
Eric Sizemore - https://www.secondversion.com
License
PHPUnit Coverage Check is licensed under the MIT License.
All versions of phpunit-coverage-check with dependencies
ext-libxml Version *
ext-simplexml Version *
symfony/console Version ^7.1