matthiasnoback/behat-local-code-coverage-extension

There is no license information available for the latest version (v0.5.0) of this package.

v0.5.0 2021-03-31 07:44 UTC

This package is auto-updated.

Last update: 2024-11-27 14:28:39 UTC


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.