PHPackages                             leanphp/behat-code-coverage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. leanphp/behat-code-coverage

ActiveLibrary[Testing &amp; Quality](/categories/testing)

leanphp/behat-code-coverage
===========================

Generate Code Coverage reports for Behat tests

v3.4.1(8y ago)50359.8k↓35.4%23[8 issues](https://github.com/leanphp/behat-code-coverage/issues)[5 PRs](https://github.com/leanphp/behat-code-coverage/pulls)2BSD-2-ClausePHPPHP &gt;=5.6CI failing

Since Apr 5Pushed 4y ago6 watchersCompare

[ Source](https://github.com/leanphp/behat-code-coverage)[ Packagist](https://packagist.org/packages/leanphp/behat-code-coverage)[ RSS](/packages/leanphp-behat-code-coverage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (12)Used By (2)

behat-code-coverage
===================

[](#behat-code-coverage)

[![License](https://camo.githubusercontent.com/c1abb9ebe4024a77392fa4c53eccb54a55418b3997355654e2255d09abbf142f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c65616e7068702f62656861742d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](#License)[![Latest Stable Version](https://camo.githubusercontent.com/28c7fcbc82169402d36b69e9260ef48825487d84f733bbb2f88be2f9a06e50af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65616e7068702f62656861742d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leanphp/behat-code-coverage)[![Total Downloads](https://camo.githubusercontent.com/02aaa09059f955b52a67b7e75dccb36645bf82bf486bbf16e7b6a82fb2eb845a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616e7068702f62656861742d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leanphp/behat-code-coverage)[![Travis](https://camo.githubusercontent.com/2dbc54ef5bff68840fafae5111b2d55553bed0fe5d9817d0d9ece7ed1887a248/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c65616e7068702f62656861742d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/leanphp/behat-code-coverage)[![AppVeyor](https://camo.githubusercontent.com/9f42dc0a8dedf2997fed564c3a3e5c905ed0bfee43c08dabbc886593ab5362c3/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f6c65616e7068702f62656861742d636f64652d636f7665726167652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://ci.appveyor.com/project/leanphp/behat-code-coverage)[![Pre Release](https://camo.githubusercontent.com/0054f086ed11f26f78b6a58adea0679acd26c96ae1010c951ad6816c5a0be6fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6c65616e7068702f62656861742d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leanphp/behat-code-coverage)

[behat-code-coverage](https://github.com/leanphp/behat-code-coverage) is a [Behat](http://behat.org/en/v2.5/) extension that generates Code Coverage reports for [Behat](http://behat.org/en/v2.5/) tests.

Generating Code Coverage reports allows you to to analyze which parts of your codebase are tested and how well. However, Code Coverage alone should NOT be used as a single metric defining how good your tests are.

**Note!** This is a maintained fork of [vipsoft/code-coverage-extension](https://github.com/vipsoft/code-coverage-extension), including codebase for [vipsoft/code-coverage-common](https://github.com/vipsoft/code-coverage-common) package with compatible version numbers for stable releases.

Requirements
------------

[](#requirements)

- PHP 5.6+ / 7.0+
- [Behat v3](http://behat.org/en/v2.5/)
- [Xdebug](https://xdebug.org/) or [phpdbg](http://phpdbg.com/) extension enabled

Change Log
----------

[](#change-log)

Please see [CHANGELOG.md](CHANGELOG.md) for information on recent changes.

Install
-------

[](#install)

Install this package as a development dependency in your project:

```
$ composer require --dev leanphp/behat-code-coverage

```

Enable extension by editing `behat.yml` of your project:

```
default:
  extensions:
    LeanPHP\Behat\CodeCoverage\Extension:
      drivers:
        - local
      filter:
        whitelist:
          include:
            directories:
              'src': ~
      report:
        format:   html
        options:
          target: build/behat-coverage
```

This will sufficient to enable Code Coverage generation in `html` format in `build/behat-coverage` directory. This extension supports various [Configuration options](#configuration-options). For a fully annotated example configuration file check [Configuration section](#configuration).

Usage
-----

[](#usage)

If you execute `bin/behat` command, you will see code coverage generated in `target` (i.e. `build/behat-coverage`) directory (in `html` format):

```
$ bin/behat

```

### Running with phpdbg

[](#running-with-phpdbg)

This extension now supports [phpdbg](http://phpdbg.com/), which results in faster execution when using more recent versions of PHP. Run `phpspec` via [phpdbg](http://phpdbg.com/):

```
$ phpdbg -qrr bin/behat run

```

Configuration
-------------

[](#configuration)

You can see fully annotated `behat.yml` example file below, which can be used as a starting point to further customize the defaults of the extension. The configuration file below has all of the \[Configuration Options\](#Configuration Options).

```
# behat.yml
# ...
default:
  extensions:
    LeanPHP\Behat\CodeCoverage\Extension:
      # http auth (optional)
      auth:        ~
      # select which driver to use when gatherig coverage data
      drivers:
        - local     # local Xdebug driver
      # filter options
      filter:
        forceCoversAnnotation:                false
        mapTestClassNameToCoveredClassName:   false
        whitelist:
          addUncoveredFilesFromWhitelist:     true
          processUncoveredFilesFromWhitelist: false
          include:
            directories:
              'src': ~
              'tests':
                suffix: '.php'
#           files:
#             - script1.php
#             - script2.php
#         exclude:
#           directories:
#             'vendor': ~
#             'path/to/dir':
#               'suffix': '.php'
#               'prefix': 'Test'
#           files:
#             - tests/bootstrap.php
      # report configuration
      report:
        # report format (html, clover, php, text)
        format:    html
        # report options
        options:
          target: build/behat-coverage/html
```

### Configuration Options

[](#configuration-options)

- `auth` - HTTP authentication options (optional).

- `create` (`method` / `path`) - override options for create method:
    - `method` - specify a method (default: `POST`)
    - `path` - specify path (default: `/`)
- `read` (`method` / `path`) - override options (method and path) for read method.
    - `method` - specify a method (default: `GET`)
    - `path` - specify path (default: `/`)
- `delete` (`method` / `path`) - override options (method and path) for delete method.
    - `method` - specify a method (default: `DELETE`)
    - `path` - specify path (default: `/`)
- `drivers` - a list of drivers for gathering code coverage data:
    - `local` - local Xdebug driver (default).
    - `remote` - remote Xdebug driver (disabled by default).
- `filter` - various filter options:
    - `forceCoversAnnotation` - (default: `false`)
    - `mapTestClassNameToCoveredClassName` - (default: `false`)
    - `whiltelist` - whitelist specific options:
        - `addUncoveredFilesFromWhiltelist` - (default: `true`)
        - `processUncoveredFilesFromWhitelist` - (default: `false`)
        - `include` - a list of files or directories to include in whitelist:
            - `directories` - key containing whitelisted directories to include.
                - `suffix` - suffix for files to be included (default: `'.php'`)
                - `prefix` - prefix of files to be included (default: `''`) (optional)
            - `files` - a list containing whitelisted files to include.
        - `exclude` - a list of files or directories to exclude from whitelist:
            - `directories` - key containing whitelisted directories to exclude.
                - `suffix` - suffix for files to be included (default: `'.php'`)
                - `prefix` - prefix of files to be included (default: `''`) (optional)
            - `files` - key containing whitelisted files to exclude.
- `report` - reporter options:
    - `format` - specify report format (`html`, `clover`, `php`, `text`)
    - `options` - format options:
        - `target` - target/output directory

Authors
-------

[](#authors)

Copyright (c) 2017 ek9  ().

Copyright (c) 2013-2016 Anthon Pang, Konstantin Kudryashov [everzet](http://github.com/everzet) and [various contributors](https://github.com/leanphp/behat-code-coverage/graphs/contributors)for portions of code from [vipsoft/code-coverage-extension](https://github.com/vipsoft/code-coverage-extension) and [vipsoft/code-coverage-common](https://github.com/vipsoft/code-coverage-common) projects.

License
-------

[](#license)

Licensed under [BSD-2-Clause License](LICENSE).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 66.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~12 days

Total

11

Last Release

2931d ago

Major Versions

v2.5.5 → v3.0.02017-04-08

PHP version history (2 changes)v2.5.5PHP &gt;=5.3.10

v3.1.0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d6dac9ce7668238177e9047f61b5d9ad52087c6f27e1ef1d211fa62727293fd?d=identicon)[ek9](/maintainers/ek9)

---

Top Contributors

[![ek9](https://avatars.githubusercontent.com/u/17393048?v=4)](https://github.com/ek9 "ek9 (131 commits)")[![robocoder](https://avatars.githubusercontent.com/u/922051?v=4)](https://github.com/robocoder "robocoder (51 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (5 commits)")[![chartinger](https://avatars.githubusercontent.com/u/1876970?v=4)](https://github.com/chartinger "chartinger (3 commits)")[![thewilkybarkid](https://avatars.githubusercontent.com/u/1784740?v=4)](https://github.com/thewilkybarkid "thewilkybarkid (2 commits)")[![andreybolonin](https://avatars.githubusercontent.com/u/2576509?v=4)](https://github.com/andreybolonin "andreybolonin (2 commits)")[![dannylewis-sheffield](https://avatars.githubusercontent.com/u/25520?v=4)](https://github.com/dannylewis-sheffield "dannylewis-sheffield (1 commits)")[![DarkSide666](https://avatars.githubusercontent.com/u/1969119?v=4)](https://github.com/DarkSide666 "DarkSide666 (1 commits)")

---

Tags

behatbehat-extensioncode-coveragecoverage-extensioncoverage-generationcoverage-reportphpphp7phpdbgtesting-toolsxdebugtestcoveragecodeBDDtestsreportBehatgenerationcloverbuildgeneratereportscode coveragescenario

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/leanphp-behat-code-coverage/health.svg)

```
[![Health](https://phpackages.com/badges/leanphp-behat-code-coverage/health.svg)](https://phpackages.com/packages/leanphp-behat-code-coverage)
```

###  Alternatives

[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[vipsoft/code-coverage-extension

Behat code coverage collector

2186.5k2](/packages/vipsoft-code-coverage-extension)[friends-of-phpspec/phpspec-code-coverage

Generate Code Coverage reports for PhpSpec tests

202.6M125](/packages/friends-of-phpspec-phpspec-code-coverage)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[polishsymfonycommunity/symfony-mocker-container

Provides base Symfony dependency injection container enabling service mocking.

1468.0M237](/packages/polishsymfonycommunity-symfony-mocker-container)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
