https://github.com/peridot-php/peridot-code-coverage-reporters
Code coverage reporters for Peridot.
https://github.com/peridot-php/peridot-code-coverage-reporters
Last synced: about 1 year ago
JSON representation
Code coverage reporters for Peridot.
- Host: GitHub
- URL: https://github.com/peridot-php/peridot-code-coverage-reporters
- Owner: peridot-php
- Created: 2014-10-08T16:38:06.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T09:29:48.000Z (over 8 years ago)
- Last Synced: 2025-05-07T21:04:40.858Z (about 1 year ago)
- Language: PHP
- Homepage: http://peridot-php.github.io/
- Size: 33.2 KB
- Stars: 2
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Peridot Code Coverage Reporters
[](https://packagist.org/packages/peridot-php/peridot-code-coverage-reporters)
[](https://travis-ci.org/peridot-php/peridot-code-coverage-reporters)
[](https://scrutinizer-ci.com/g/peridot-php/peridot-code-coverage-reporters/?branch=master)
[](https://codecov.io/gh/peridot-php/peridot-code-coverage-reporters)
[](https://gitter.im/peridot-php/lobby)
## Installation
Add this package as a dependency:
composer require --dev peridot-php/peridot-code-coverage-reporters
Then register the reporters in your `peridot.php` configuration:
```php
use Evenement\EventEmitterInterface;
use Peridot\Reporter\CodeCoverage\CodeCoverageReporter;
use Peridot\Reporter\CodeCoverageReporters;
return function (EventEmitterInterface $emitter) {
$coverage = new CodeCoverageReporters($emitter);
$coverage->register();
$emitter->on('code-coverage.start', function (CodeCoverageReporter $reporter) {
$reporter->addDirectoryToWhitelist(__DIR__ . '/src');
});
};
```
## Usage
This package provides several *Peridot* reporters that can be used via the
`--reporter` option:
- `html-code-coverage`
- `text-code-coverage`
- `clover-code-coverage`
- `xml-code-coverage`
- `crap4j-code-coverage`
- `php-code-coverage`
These reporters are all driven by [php-code-coverage], which requires the use of
either the `phpdbg` executable, or the `xdebug` PHP extension in order to
produce coverage reports.
### With `phpdbg`
Where available, `phpdbg` is generally recommended for faster coverage
reporting. Most system-level package management tools should be able to install
a version of `phpdbg` with minimal hassle. Under [Homebrew], for example,
`phpdbg` can be installed like so:
brew tap homebrew/homebrew-php && brew install php71 --with-phpdbg
Once installed, `phpdbg -qrr` can be used in place of `php` when executing
scripts, including the `peridot` binary, allowing code coverage to be generated:
phpdbr -qrr vendor/bin/peridot --reporter spec --reporter html-code-coverage
The above command will print spec-style output while the suite runs, and
generate an HTML coverage report once the suite has completed.
### With `xdebug`
Use of `xdebug` is no longer recommended, because of the significantly worse
performance compared to `phpdbg`. If `phpdbg` is not an option, simply make sure
the `xdebug` extension is enabled when running `peridot`:
vendor/bin/peridot --reporter spec --reporter html-code-coverage
The above command will print spec-style output while the suite runs, and
generate an HTML coverage report once the suite has completed.
[homebrew]: https://brew.sh/
[php-code-coverage]: https://github.com/sebastianbergmann/php-code-coverage