- Download latest release (currently 1.0.11) for Windows for your version of PHP and the correct format (ts or nts) from PECL
- Unzip downloaded package and copy the files
php_pcov.dll
andphp_pcov.pdb
to your PHP extensions directory, e.g.C:\bin\php\php-7.4.27-Win32-vc15-x64\ext\
- Modify your
php.ini
so that PCOV is loaded. Therefore addextension=pcov
:
..
extension=fileinfo
extension=gd2
extension=pcov
..
- Reload your Webserver, e.g. Apache or Nginx
Create a PHPUnit configuration file with the wizard by running:
.\vendor\bin\phpunit --generate-configuration
Then open the file phpunit.xml
and add directories to be excluded, otherwise the command will output too many errors:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">.</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</coverage>
</phpunit>
Add PHPUnit Code Coverage package by requiring with Composer:
composer require --dev phpunit/php-code-coverage
.\vendor\bin\phpunit tests --coverage-html ./html