I am working on project that based on Yii framework, and we have many tests that we added programatically to test suite, so we are not using phpunit.xml file to configure tests.
The question is, how I would exclude some directories from code coverage reports(for example Yii folder). The most solutions I found are based on blacklist/whitelists configuration option in xml file.
I also found that there is --filter option for phpunit command, but I couldn't find any example how I could use it to exclude complete directory(or few of them).
--filter
is used to filter the tests that are execute in the current run of phpunit.
You can use it so say "only execute --filter MyTestClass
or --filter testStuffThatBrokeAndIOnlyWantToRunThatOneSingleTest
but is has nothing to do with code coverage.
The --filter
has nothing to do with the <filter>
in the xml configuration even so they have the same name :)
If you use whitelist on your own source
folder that should do the job in most of the cases.
Whitelist docs:
http://phpunit.de/manual/current/en/phpunit-book.html#appendixes.configuration.blacklist-whitelist
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With