Skip to content

Instantly share code, notes, and snippets.

@MrRio
Last active February 16, 2023 10:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MrRio/45c369d9dca5cb9e85aa8f5b53714b97 to your computer and use it in GitHub Desktop.
Save MrRio/45c369d9dca5cb9e85aa8f5b53714b97 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