In my D8 project I have Unit and Kernel tests. Running them (via CLI) without "--coverage-html" is fine. Unit tests in general are ~300ms, Kernels are around 3s (of course based on the size of dependencies and the amount of the test cases).

But when I also want to have code coverage Unit tests are fast as usual but Kernel tests are incredible slow (10-20 minutes).

I started to use filters and whitelisting in the phpunit config file, but that affects only the result (the generated coverage files) but not the speed, which makes the impression that PHPUnit also loops through the Kernel Dependencies (such as core files).

Has anyone met this problem before? What can cause it?

Here is my filtering options:

        <directory suffix=".php">./web/modules/custom/test_module</directory>

1 Answer 1


A kernel tests actually installs Drupal (in-memory only, but still), that means it runs thounsands and thousands of lines of code.

You can't really do anything to change that, xdebug (I guess you use that) would actually have to support a native whitelist to keep the overhead minimal, but that would in turn also result in overhead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.