dev-master
9999999-dev
The Requires
v0.1.1
0.1.1.0
The Requires
v0.1.0
0.1.0.0
The Requires
This extension can be used to collect code coverage data from the web server that's called by Mink while running Behat., (*1)
To use this extension, enable it under extensions
and for every suite that needs remote code coverage collection, set remote_coverage_enabled
to true
., (*2)
default: extensions: BehatRemoteCodeCoverage\RemoteCodeCoverageExtension: target_directory: '%paths.base%/var/coverage' suites: default: remote_coverage_enabled: true
Now modify the front controller of your web application to look like this:, (*3)
use LiveCodeCoverage\RemoteCodeCoverage; $shutDownCodeCoverage = RemoteCodeCoverage::bootstrap( (bool)getenv('CODE_COVERAGE_ENABLED'), sys_get_temp_dir(), __DIR__ . '/../phpunit.xml.dist' ); // Run your web application now... // This will save and store collected coverage data: $shutDownCodeCoverage();
Make sure to modify the call to RemoteCodeCoverage::bootstrap()
if needed:, (*4)
.cov
).phpunit.xml(.dist)
file. This file is only used for its code coverage filter configuration.After a test run, the extension makes a special call (/?code_coverage_export=true&...
) to the web application. The response to this call contains the serialized code coverage data. It will be stored as a file in target_directory
, named after the test suite itself, e.g. default.cov
., (*5)
You can use these .cov
files to generate nice reports, using phpcov
., (*6)
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., (*7)
To (also) generate (local) code coverage during a Behat test run, use the LocalCodeCoverageExtension
., (*8)