Search by

shipmonk / turbocov-phpunit

shipmonk

PHPUnit code coverage driver for the turbocov extension, which runs covered code at plain PHP speed

Package info

github.com/shipmonk-rnd/turbocov-phpunit

pkg:composer/shipmonk/turbocov-phpunit

Statistics

Installs: 17

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2026-11-17 11:50 UTC

This package is auto-updated.

Last update: 2026-11-17 12:09:33 UTC


README

Code coverage driver that connects PHPUnit to the turbocov extension.

turbocov collects line coverage, and covered code runs at the speed of plain PHP. Read the README of the extension for the mechanism, the settings and the limits.

Requirements

  • PHP 8.4 or 8.5
  • PHPUnit 13.3 or later
  • The turbocov extension

Earlier versions of PHPUnit cannot load a custom coverage driver.

Installation

pie install shipmonk/turbocov
composer require --dev shipmonk/turbocov-phpunit

Usage

Set the driver in phpunit.xml:

<coverage driver="ShipMonk\Turbocov\TurbocovDriver">
    <report>
        <clover outputFile="clover.xml"/>
    </report>
</coverage>

Tell the extension which files to collect, then run PHPUnit:

php -d turbocov.collect_paths=src vendor/bin/phpunit
  • turbocov.collect_paths takes files and directories. The <source> element of phpunit.xml does not set it.
  • Set it with -d or in php.ini. An <ini> element in phpunit.xml has no effect, because PHP reads this setting only when it starts.
  • PHPUnit gives the setting to the processes of tests that run in a separate process.

PHPUnit shows the driver in its header:

Runtime:       PHP 8.5.12 with turbocov 0.1.0

Coverage of changed files only

turbocov has no cost for files that are not in turbocov.collect_paths. To collect coverage only for the files that a branch changes:

git diff --name-only --diff-filter=AMR origin/master...HEAD -- '*.php' > changed.txt
php -d turbocov.collect_paths=@changed.txt vendor/bin/phpunit

When turbocov cannot collect coverage

The driver stops the run before the first test. PHPUnit shows the reason:

An error occurred inside PHPUnit.

Message:  turbocov cannot collect coverage: turbocov.collect_paths is not set

The driver does not continue without coverage. A run with a wrong setup must not give an empty report.

Limits

  • Line coverage only. No branch coverage and no path coverage.
  • The driver uses classes of phpunit/php-code-coverage that have no promise of backward compatibility. The tests of this package run with the lowest and the highest supported version.

Development

The tests need the turbocov extension in php.ini. A -d extension= option is not sufficient, because the tests start more PHP processes.

composer check     # all checks
composer fix:cs    # fix the coding style

License

MIT. See LICENSE.