Skip to content

Instantly share code, notes, and snippets.

@bsdnomad
Forked from MrRio/README.md
Created February 16, 2023 10:57
Show Gist options
  • Save bsdnomad/328ea6d292762d2a43c21f90f9e6e653 to your computer and use it in GitHub Desktop.
Save bsdnomad/328ea6d292762d2a43c21f90f9e6e653 to your computer and use it in GitHub Desktop.
Speed up your phpunit code coverage output in Laravel

Speed up your phpunit code coverage output in Laravel.

Your coverage reports are slowed down by xdebug tracing within Laravel and packages you depend on, despite them not being in your final coverage report. This moves the filtering from phpunit into xdebug itself.

Before: Time: 5.33 minutes, Memory: 10.00 MB

After: Time: 1.5 minutes, Memory: 10.00 MB

./vendor/bin/phpunit --coverage-html=results/coverage

More info: sebastianbergmann/phpunit#3272

<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
protected function setUp(): void
{
if (function_exists('xdebug_set_filter')) {
\xdebug_set_filter(
\XDEBUG_FILTER_CODE_COVERAGE,
\XDEBUG_PATH_WHITELIST,
[
'./app/'
]
);
}
parent::setUp();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment