matthiasnoback / behat-local-code-coverage-extension
Installs: 462 436
Dependents: 1
Suggesters: 0
Security: 0
Stars: 26
Watchers: 4
Forks: 9
Open Issues: 0
Requires
- php: >=7.0
- behat/behat: ^3.4
- matthiasnoback/live-code-coverage: ^1.0
README
This extension can be used to collect code coverage data when using Behat.
Install
$ composer require --dev matthiasnoback/behat-local-code-coverage-extension
You'll also need Xdebug installed and enabled in your PHP installation (or Docker image) and also code coverage. Something like:
zend_extension=xdebug.so
xdebug.coverage_enable=1
Use
To use this extension, enable it under extensions
and for every suite that needs local code coverage collection, set local_coverage_enabled
to true
.
default: extensions: BehatLocalCodeCoverage\LocalCodeCoverageExtension: target_directory: '%paths.base%/var/coverage' suites: default: local_coverage_enabled: true
After a test run, you'll find a .cov
file in the target directory for every suite that has local code coverage enabled.
You can use these .cov
files to generate nice reports, using phpcov
.
You could even configure PHPUnit to generate a .cov
file in the same directory, so you can combine coverage data from PHPUnit and Behat in one report.