/PhpSpecCodeCoverageExtension

Extension for PhpSpec that brings Code Coverage.

Primary LanguagePHPMIT LicenseMIT

PhpSpec Code Coverage

Add it to your composer.json file to install with Composer:

composer require henrikbjorn/phpspec-code-coverage:^2.0

Enable it in your phpspec.yml file:

extensions:
    - PhpSpec\Extension\CodeCoverageExtension

Now run your specs with the normal phpspec run and voila your code coverage will be available in coverage.

Configuration Options

It is possible to control a bit out how the code coverage is done through phpspec.yml. This is done by adding a code_coverage key which takes a hash of options.

  • whitelist takes an array of directories to whitelist (default: lib, src).
  • whitelist_files takes an array of files to whitelist (default: none).
  • blacklist takes an array of directories to blacklist
  • blacklist_files takes an array of files to blacklist
  • format (optional) could be one or many of: clover, php, text, html (default html)
  • output takes a location relative to the place you are running phpspec run (default: coverage). If you configure multiple formats, takes a hash of format:output e.g.
code_coverage:
  format:
    - html
    - clover
  output:
    html: coverage
    clover: coverage.xml
  • show_uncovered_files for including uncovered files in coverage reports (default true)
  • lower_upper_bound for coverage (default 35)
  • high_lower_bound for coverage (default 70)

Running with phpdbg

For faster execution, run phpspec with phpdbg instead of xdebug:

phpdbg -qrr phpspec run