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

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

alexyav/phpspec-code-coverage
=============================

Generate Code Coverage reports for PhpSpec tests

v4.3.3(5y ago)04MITPHPPHP &gt;= 7.1.3

Since Feb 11Pushed 5y agoCompare

[ Source](https://github.com/AlexyAV/phpspec-code-coverage)[ Packagist](https://packagist.org/packages/alexyav/phpspec-code-coverage)[ Docs](https://github.com/friends-of-phpspec/phpspec-code-coverage)[ RSS](/packages/alexyav-phpspec-code-coverage/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (4)Versions (20)Used By (0)

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

[](#phpspec-code-coverage)

[![Latest Stable Version](https://camo.githubusercontent.com/d0ae1c940c7a23703d1ea3d45d3880d5c198cdd81e35362cb2f353d9b70e4a9a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667269656e64732d6f662d706870737065632f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/friends-of-phpspec/phpspec-code-coverage)[![Total Downloads](https://camo.githubusercontent.com/51d32d217efa0a142c570ef818b8b6b79d8227ed6d6a39c6872b6c16b3bfd253/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f667269656e64732d6f662d706870737065632f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/friends-of-phpspec/phpspec-code-coverage)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/57129eaa0304736b4bf377a59a24572919a9d36104fb4115e54e1a71384decb9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f667269656e64732d6f662d706870737065632f706870737065632d636f64652d636f7665726167652f6d61737465723f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/friends-of-phpspec/phpspec-code-coverage/?branch=master)[![Travis](https://camo.githubusercontent.com/5ead584d5cfeaf2f85f92a12461172c683bc8ac1f750447cd7d88a0328c8beb1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f667269656e64732d6f662d706870737065632f706870737065632d636f64652d636f7665726167652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/friends-of-phpspec/phpspec-code-coverage)

[phpspec-code-coverage](https://github.com/friends-of-phpspec/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.

[![phpspec-code-coverage console report](https://camo.githubusercontent.com/22dabff92dd18b7366b737cf95e0189f191804a4fa4099bafb753926bac2228a/68747470733a2f2f692e696d6775722e636f6d2f425531305a41562e706e67)](https://camo.githubusercontent.com/22dabff92dd18b7366b737cf95e0189f191804a4fa4099bafb753926bac2228a/68747470733a2f2f692e696d6775722e636f6d2f425531305a41562e706e67)[![phpspec-code-coverage HTML report](https://camo.githubusercontent.com/442573a9c79d1cbaf0fa7f381cc4fcec7e7ec277af62ee32c99fb8f70e36e7d2/68747470733a2f2f692e696d6775722e636f6d2f367841435231672e706e67)](https://camo.githubusercontent.com/442573a9c79d1cbaf0fa7f381cc4fcec7e7ec277af62ee32c99fb8f70e36e7d2/68747470733a2f2f692e696d6775722e636f6d2f367841435231672e706e67)

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

[](#requirements)

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

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

```

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

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

This will sufficient to enable Code Coverage generation by using defaults provided by the extension. This extension supports various [configuration options](#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

```

**Note!** When generating Code Coverage reports make sure PHP processes run via CLI are not memory limited (i.e. `memory_limit` set to `-1` in `/etc/php/cli/php.ini`).

### Running with phpdbg

[](#running-with-phpdbg)

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

```
$ phpdbg -qrr phpspec run

```

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

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](#Options).

```
# phpspec.yml
# ...
extensions:
  # ... other extensions ...
  # friends-of-phpspec/phpspec-code-coverage
  FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension:
    # Specify a list of formats in which code coverage report should be
    # generated.
    # Default: [html]
    format:
      - text
      - html
      #- clover
      #- php
      #- xml
    #
    # 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
      #xml: coverage
    #
    # 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
```

### Options

[](#options)

- `format` (optional) a list of formats in which code coverage should be generated. Can be one or many of: `clover`, `php`, `text`, `html`, `xml` (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-2018 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

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity67

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

Recently: every ~206 days

Total

18

Last Release

2150d ago

Major Versions

v1.0.1 → v2.1.02017-02-12

v2.1.0 → v3.0.12017-02-14

v3.x-dev → v4.0.02017-10-17

PHP version history (6 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

v4.0.0PHP ^7.0

v4.2.0PHP ^7.1

v4.3.3PHP &gt;= 7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/359f6a15cf5e394411373f6593f62dcbf0d21aea441350b6afaa8fd5afedd94d?d=identicon)[avpretty](/maintainers/avpretty)

---

Top Contributors

[![ek9](https://avatars.githubusercontent.com/u/17393048?v=4)](https://github.com/ek9 "ek9 (98 commits)")[![henrikbjorn](https://avatars.githubusercontent.com/u/19725?v=4)](https://github.com/henrikbjorn "henrikbjorn (45 commits)")[![shulard](https://avatars.githubusercontent.com/u/482993?v=4)](https://github.com/shulard "shulard (23 commits)")[![drupol](https://avatars.githubusercontent.com/u/252042?v=4)](https://github.com/drupol "drupol (10 commits)")[![kwisatz](https://avatars.githubusercontent.com/u/237949?v=4)](https://github.com/kwisatz "kwisatz (7 commits)")[![jaylinski](https://avatars.githubusercontent.com/u/1668766?v=4)](https://github.com/jaylinski "jaylinski (5 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)")[![AlexyAV](https://avatars.githubusercontent.com/u/5259115?v=4)](https://github.com/AlexyAV "AlexyAV (2 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)")[![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)")[![ptondereau](https://avatars.githubusercontent.com/u/4287777?v=4)](https://github.com/ptondereau "ptondereau (2 commits)")[![rnijveld](https://avatars.githubusercontent.com/u/193783?v=4)](https://github.com/rnijveld "rnijveld (2 commits)")[![piorek](https://avatars.githubusercontent.com/u/743617?v=4)](https://github.com/piorek "piorek (1 commits)")[![digitalkaoz](https://avatars.githubusercontent.com/u/293591?v=4)](https://github.com/digitalkaoz "digitalkaoz (1 commits)")

---

Tags

testcoveragetestsreportspecphpspeccode coverage

### Embed Badge

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

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

###  Alternatives

[friends-of-phpspec/phpspec-code-coverage

Generate Code Coverage reports for PhpSpec tests

202.6M125](/packages/friends-of-phpspec-phpspec-code-coverage)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

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

Generate Code Coverage reports for Behat tests

50359.8k2](/packages/leanphp-behat-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)
