- Notifications
You must be signed in to change notification settings - Fork39
Generate Code Coverage reports for PhpSpec tests
License
leanphp/phpspec-code-coverage
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
phpspec-code-coverage is aPhpSpec extension that generates CodeCoverage reports forPhpSpec tests.
Generating Code Coverage reports allows you to to analyze which parts of yourcodebase are tested and how well. However, Code Coverage alone should NOT beused as a single metric defining how good your tests are.
Note! This is a maintained fork ofhenrikbjorn/phpspec-code-coveragepackage with compatible version numbers for stable releases.
- PHP 7+ (forPhpSpec v4+) or PHP 5.6+ (forPhpSpec v3)
- Xdebug orphpdbg extension enabled (PHP 7+ is required for codegeneration to work withphpdbg).
Please seeCHANGELOG.md for information on recent changes.
Install this package as a development dependency in your project:
$ composer require --dev leanphp/phpspec-code-coverageEnable extension by editingphpspec.yml of your project:
extensions:LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension:~
This will sufficient to enable Code Coverage generation by using defaultsprovided by the extension. This extension supports variousconfigurationoptions. For a fully annotated example configurationfile checkConfiguration section.
If you executephpspec run command, you will see code coverage generated incoverage directory (inhtml format):
$ bin/phpspec runNote! When generating Code Coverage reports make sure PHP processes run viaCLI are not memory limited (i.e.memory_limit set to-1 in/etc/php/cli/php.ini).
This extension now supportsphpdbg, which results in faster execution whenusing more recent versions of PHP. Runphpspec viaphpdbg:
$ phpdbg -qrr phpspec runNote! PHP 7+ is required for code generation to work withphpdbg.
You can see fully annotatedphpspec.yml example file below, which can be usedas a starting point to further customize the defaults of the extension. Theconfiguration file below has all of theConfiguration Options.
# phpspec.yml# ...extensions:# ... other extensions ...# leanphp/phpspec-code-coverageLeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension:# Specify a list of formats in which code coverage report should be# generated.# Default: [html]format: -text -html#- clover#- php#- xml## Specify output file/directory where code coverage report will be# generated. You can configure different output file/directory per# enabled format.# Default: coverageoutput:html:coverage#clover: coverage.xml#php: coverage.php#xml: coverage## Should uncovered files be included in the reports?# Default: true#show_uncovered_files: true## Set lower upper bound for code coverage# Default: 35#lower_upper_bound: 35## Set high lower bound for code coverage# Default: 70#high_lower_bound: 70## Whilelist directories for which code generation should be done# Default: [src, lib]#whitelist: -src -lib## Whiltelist files for which code generation should be done# Default: empty#whilelist_files:#- app/bootstrap.php#- web/index.php## Blacklist directories for which code generation should NOT be done#blacklist:#- src/legacy## Blacklist files for which code generation should NOT be done#blacklist_files:#- lib/bootstrap.php
format(optional) a list of formats in which code coverage should begenerated. Can be one or many of:clover,php,text,html,xml(defaulthtml)Note: When usingcloverformat option, you have to configure specificoutputfile for thecloverformat (see below).output(optional) sets an output file/directory where specific codecoverage format will be generated. If you configure multiple formats, takesa hash offormat:output(e.g.clover:coverage.xml) (defaultcoverage)show_uncovered_files(optional) for including uncovered files in coveragereports (defaulttrue)lower_upper_bound(optional) sets lower upper bound for code coverage(default35).high_lower_bound(optional) sets high lower bound for code coverage(default70)whitelisttakes an array of directories to whitelist (default:lib,src).whitelist_filestakes an array of files to whitelist (default: none).blacklisttakes an array of directories to blacklist (default:test, vendor, spec)blacklist_filestakes an array of files to blacklist
Copyright (c) 2017-2018 ek9dev@ek9.co (https://ek9.co).
Copyright (c) 2013-2016 Henrik Bjornskov, for portions of code fromhenrikbjorn/phpspec-code-coverage project.
Licensed underMIT License.
About
Generate Code Coverage reports for PhpSpec tests
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.


