As far as I understand one can exclude files and directories from code coverage by name but is it possible to exclude by matching a pattern ?
I ask this because I don't want to mention the path to all my view
sub-folders one by one in my phpunit.xml
. Something like <exclude>*/view</exclude>
perhaps ? By this I mean "exclude all view
folders wherever you reach them".
Yes, you can specify file patterns to exclude from Code Coverage. Here is a sample of one of my PHPUnit.xml.dist files.
<!-- Add files not covered with tests into Code Coverage Analysis -->
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".class">.</directory>
<directory suffix=".fn">.</directory>
<directory suffix=".php">.</directory>
<exclude>
<directory>ExternalLibraries</directory>
</exclude>
</whitelist>
</filter>
The PHPUnit Manual for Code Coverage and then the Including/Excluding files for Code Coverage sections of the manual will show you additional options to specify the file patterns by directory or name.
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