phpunit / phpcov
CLI frontend for php-code-coverage
Fund package maintenance!
sebastianbergmann
Installs: 15 242 212
Dependents: 611
Suggesters: 3
Security: 0
Stars: 227
Watchers: 11
Forks: 58
Open Issues: 11
Requires
- php: >=8.2
- phpunit/php-code-coverage: ^11.0.8
- phpunit/php-file-iterator: ^5.1
- phpunit/phpunit: ^11.5.1
- sebastian/cli-parser: ^3.0.2
- sebastian/diff: ^6.0.2
- sebastian/version: ^5.0.2
README
phpcov
phpcov is a command-line frontend for the php-code-coverage library.
Installation
This tool is distributed as a PHP Archive (PHAR):
$ wget https://phar.phpunit.de/phpcov.phar
$ php phpcov.phar --version
Using Phive is the recommended way for managing the tool dependencies of your project:
$ phive install phpcov
$ ./tools/phpcov --version
It is not recommended to use Composer to download and install this tool.
Usage
Executing a PHP script and generating code coverage in Clover XML format
$ phpcov execute --clover coverage.xml script.php
phpcov 8.1.0 by Sebastian Bergmann.
Generating code coverage report in Clover XML format ... done
Merging exported php-code-coverage objects stored in *.cov files
$ parallel --gnu ::: \
'phpunit --coverage-php /tmp/coverage/FooTest.cov tests/FooTest' \
'phpunit --coverage-php /tmp/coverage/BarTest.cov tests/BarTest'
$ phpcov merge --clover /tmp/clover.xml /tmp/coverage
phpcov 8.1.0 by Sebastian Bergmann.
Generating code coverage report in Clover XML format ... done
Patch Coverage
$ git diff HEAD^1 > /tmp/patch.txt
$ phpunit --coverage-php /tmp/coverage.cov
$ phpcov patch-coverage --path-prefix /path/to/project /tmp/coverage.cov /tmp/patch.txt
phpcov 8.1.0 by Sebastian Bergmann.
1 / 2 changed executable lines covered (50.00%)
Changed executable lines that are not covered:
Example.php:11