PHPackages                             hanken/phpspec-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. hanken/phpspec-code-coverage

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

hanken/phpspec-code-coverage
============================

Generate Code Coverage reports for PhpSpec tests

v3.2.3(6y ago)019.7k↑16.7%MITPHPPHP ^7.0

Since Feb 11Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (12)Used By (0)

phpspec-code-coverage
=====================

[](#phpspec-code-coverage)

[![License](https://camo.githubusercontent.com/48e383d2220a05be2c5994fc7ea9f4a8df23e48d118388b78ad8786ef40cb7f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c65616e7068702f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](#LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/757834f5b0ed89e79861dec7ccf36638e451b1e581754c18bfce6f3588913605/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65616e7068702f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leanphp/phpspec-code-coverage)[![Total Downloads](https://camo.githubusercontent.com/2fab119c2dc6af0a6ad027c0f38bfdb894e93b906c4d1bb5d440b1cdd55096d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616e7068702f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leanphp/phpspec-code-coverage)[![Travis](https://camo.githubusercontent.com/6f811021a687faf7ac0bf74436708fb528249c404c23cde88c88b80bfdf6cd9d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c65616e7068702f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/leanphp/phpspec-code-coverage)[![AppVeyor](https://camo.githubusercontent.com/9e6ab65a4cbdebc933661615fa9c0b57e97f01455780dec4ff40ab5ba3e2bd5f/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f6c65616e7068702f706870737065632d636f64652d636f7665726167652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://ci.appveyor.com/project/leanphp/phpspec-code-coverage)[![Pre Release](https://camo.githubusercontent.com/0fd7d80fcad60c8dafeeb690f875ac31eef5ef04c3bd2dd50b2a02adffdc3287/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6c65616e7068702f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leanphp/phpspec-code-coverage)

[phpspec-code-coverage](https://github.com/leanphp/phpspec-code-coverage) is a [PhpSpec](http://www.phpspec.net/en/stable) extension that generates Code Coverage reports for [PhpSpec](http://www.phpspec.net/en/stable) 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 [henrikbjorn/phpspec-code-coverage](https://github.com/henrikbjorn/PhpSpecCodeCoverageExtension)package with compatible version numbers for stable releases.

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

[](#requirements)

- PHP 5.6+ or PHP 7+
- [Xdebug](https://xdebug.org/) or [phpdbg](http://phpdbg.com/) extension enabled (PHP 7+ is required for code generation to work with [phpdbg](http://phpdbg.com/)).
- [PhpSpec v3 or v4](http://www.phpspec.net/en/stable)

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/phpspec-code-coverage

```

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

```
extensions:
  LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension: ~
```

This will sufficient to enable Code Coverage generation by using defaults provided by the extension. This extension supports various \[configuration options\](#Configuration Options). For a fully annotated example configuration file check [Configuration section](#Configuration).

Usage
-----

[](#usage)

If you execute `phpspec run` command, you will see code coverage generated in `coverage` directory (in `html` format):

```
$ bin/phpspec run

```

### 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 phpspec run

```

**Note!** PHP 7+ is required for code generation to work with [phpdbg](http://phpdbg.com/).

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

[](#configuration)

You can see fully annotated `phpspec.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).

```
# phpspec.yml
# ...
extensions:
  # ... other extensions ...
  # leanphp/phpspec-code-coverage
  LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension:
    # Specify a list of formats in which code coverage report should be
    # generated.
    # Default: [html]
    format:
      - text
      - html
      #- clover
      #- php
    #
    # Specify output file/directory where code coverage report will be
    # generated. You can configure different output file/directory per
    # enabled format.
    # Default: coverage
    output:
      html: coverage
      #clover: coverage.xml
      #php: coverage.php
    #
    # 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
```

### Configuration Options

[](#configuration-options)

- `format` (optional) a list of formats in which code coverage should be generated. Can be one or many of: `clover`, `php`, `text`, `html` (default `html`) **Note**: When using `clover` format option, you have to configure specific `output` file for the `clover` format (see below).
- `output` (optional) sets an output file/directory where specific code coverage format will be generated. If you configure multiple formats, takes a hash of `format:output` (e.g. `clover:coverage.xml`) (default `coverage`)
- `show_uncovered_files` (optional) for including uncovered files in coverage reports (default `true`)
- `lower_upper_bound` (optional) sets lower upper bound for code coverage (default `35`).
- `high_lower_bound` (optional) sets high lower bound for code coverage (default `70`)
- `whitelist` takes an array of directories to whitelist (default: `lib`, `src`).
- `whitelist_files` takes an array of files to whitelist (default: none).
- `blacklist` takes an array of directories to blacklist (default: `test, vendor, spec`)
- `blacklist_files` takes an array of files to blacklist

Authors
-------

[](#authors)

Copyright (c) 2017 ek9  ().

Copyright (c) 2013-2016 Henrik Bjornskov, for portions of code from [henrikbjorn/phpspec-code-coverage](https://github.com/henrikbjorn/PhpSpecCodeCoverageExtension) project.

License
-------

[](#license)

Licensed under [MIT License](LICENSE).

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~153 days

Recently: every ~265 days

Total

8

Last Release

2312d ago

Major Versions

v1.0.1 → v2.1.02017-02-12

v2.1.0 → v3.0.12017-02-14

PHP version history (4 changes)v1.0.1PHP &gt;=5.3.3

v2.1.0PHP ~5.3,^5.3.3||~7.0

v3.0.1PHP ~5.6||~7.0

v3.2.0PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8dff4833b989defdb3d2b35469566aab1bdef13c7fc0514499d3c478c3eede0a?d=identicon)[hanken](/maintainers/hanken)

---

Top Contributors

[![henrikbjorn](https://avatars.githubusercontent.com/u/19725?v=4)](https://github.com/henrikbjorn "henrikbjorn (45 commits)")[![ek9](https://avatars.githubusercontent.com/u/17393048?v=4)](https://github.com/ek9 "ek9 (34 commits)")[![kwisatz](https://avatars.githubusercontent.com/u/237949?v=4)](https://github.com/kwisatz "kwisatz (7 commits)")[![svemir](https://avatars.githubusercontent.com/u/154453?v=4)](https://github.com/svemir "svemir (4 commits)")[![Sam-Burns](https://avatars.githubusercontent.com/u/6594039?v=4)](https://github.com/Sam-Burns "Sam-Burns (4 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (3 commits)")[![lookitsatravis](https://avatars.githubusercontent.com/u/606978?v=4)](https://github.com/lookitsatravis "lookitsatravis (3 commits)")[![DavidGarciaCat](https://avatars.githubusercontent.com/u/7809429?v=4)](https://github.com/DavidGarciaCat "DavidGarciaCat (2 commits)")[![exu](https://avatars.githubusercontent.com/u/30776?v=4)](https://github.com/exu "exu (2 commits)")[![fesor](https://avatars.githubusercontent.com/u/172247?v=4)](https://github.com/fesor "fesor (2 commits)")[![hanken](https://avatars.githubusercontent.com/u/1201469?v=4)](https://github.com/hanken "hanken (2 commits)")[![michaldudek](https://avatars.githubusercontent.com/u/802141?v=4)](https://github.com/michaldudek "michaldudek (2 commits)")[![milan](https://avatars.githubusercontent.com/u/3963?v=4)](https://github.com/milan "milan (2 commits)")[![rnijveld](https://avatars.githubusercontent.com/u/193783?v=4)](https://github.com/rnijveld "rnijveld (2 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (1 commits)")[![digitalkaoz](https://avatars.githubusercontent.com/u/293591?v=4)](https://github.com/digitalkaoz "digitalkaoz (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![piorek](https://avatars.githubusercontent.com/u/743617?v=4)](https://github.com/piorek "piorek (1 commits)")[![renanivo](https://avatars.githubusercontent.com/u/136425?v=4)](https://github.com/renanivo "renanivo (1 commits)")[![wimvds](https://avatars.githubusercontent.com/u/777114?v=4)](https://github.com/wimvds "wimvds (1 commits)")

---

Tags

testcoveragecodetestsreportgenerationspecphpspeccloverbuildgeneratereportscode coverage

### Embed Badge

![Health badge](/badges/hanken-phpspec-code-coverage/health.svg)

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

###  Alternatives

[leanphp/behat-code-coverage

Generate Code Coverage reports for Behat tests

50359.8k2](/packages/leanphp-behat-code-coverage)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[friends-of-phpspec/phpspec-code-coverage

Generate Code Coverage reports for PhpSpec tests

202.6M125](/packages/friends-of-phpspec-phpspec-code-coverage)[benconstable/phpspec-laravel

Test your Laravel applications with PhpSpec

144347.1k15](/packages/benconstable-phpspec-laravel)

PHPackages © 2026

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