Integrates CodeCoverage with PhpSpec
DEPRECATED: CodeCoverage should not be used with spec testing in order to see how good your tests are. For that reason, and because I don't use it myself, this library is deprecated and will not receive any updates etc. For a maintained fork, you can check leanphp/phpspec-code-coverage.
Install with Composer:
composer require --dev henrikbjorn/phpspec-code-coverage
Enable it in your
extensions: - PhpSpecCodeCoverage\CodeCoverageExtension
Now run your specs with the normal
phpspec run and voilà your code coverage will be available in
It is possible to control a bit out how the code coverage is done through
phpspec.yml. This is done by
adding a hash of options to the extension key.
whitelisttakes an array of directories to whitelist (default:
whitelist_filestakes an array of files to whitelist (default: none).
blacklisttakes an array of directories to blacklist
blacklist_filestakes an array of files to blacklist
format(optional) could be one or many of:
outputtakes a location relative to the place you are running
coverage). If you configure multiple formats, takes a hash of format:output e.g.
extensions: PhpSpecCodeCoverage\CodeCoverageExtension: format: - html - clover output: html: coverage clover: coverage.xml
show_uncovered_filesfor including uncovered files in coverage reports (default
lower_upper_boundfor coverage (default
high_lower_boundfor coverage (default
Note: If the clover format option requires you to also set an output location!
For faster execution, run phpspec with phpdbg instead of xdebug:
phpdbg -qrr phpspec run
Note: The code coverage extension only works with phpdbg if you're using PHP 7. In PHP 5.6, phpdbg is missing the phpdbg_start_oplog function which is required to generate code coverage.