Reputation: 13753
I am using PHPUnit in my Codeception unit tests. I am not interested in code coverage yet, so I would like to completely disable it, especially because it delays my tests by 8..12 seconds. This becomes annoying when tests are configured to be run automatically when files change.
I debugged PHPUnit code to see why it is starting up so long and found out that it spends up to 12 seconds inside getCodeCoverageFilter
looping through getBlacklistedDirectories
and collecting filenames calling addDirectoryToBlacklist
.
Is there any way to disable processing getCodeCoverageFilter
in Codeception or PHPUnit itself without directly hacking its code?
Here is my current phpunit.xml at the root of my Laravel 5 project:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory>./vendor/</directory>
<directory>./database/</directory>
<directory>./public/</directory>
<directory>./resources/</directory>
<directory>./storage/</directory>
<directory>./tests/</directory>
</blacklist>
<whitelist>
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>
Upvotes: 0
Views: 220
Reputation: 66817
According to codeception documentation, the code coverage is enabled in codeception.yml
. Try:
coverage:
enabled: false
Or removing the key.
Upvotes: 0
Reputation: 66817
Just remove the line
<log type="coverage-html" target="coverage"/>
from your phpunit.xml
In fact, I use two xml files.
One standard phpunit.xml
that is used on a remote code inspection service, and one that I specifically named phpunit_no_code_coverage.xml
without code coverage, that I use locally while developing.
You can specify which xml file to use via phpunit's c
flag, e.g:
./phpunit -c tests/phpunit_no_code_coverage.xml --testsuite suite_name
The result is rather huge, my testsuite runs now rather fast, on average taking ~15 seconds, whereas it before took 110 seconds.
Upvotes: 1