Reputation: 25
My 'test project' contains only the Application.php and the ApplicationTest.php but the phpunit collect the coverage information about composer autoloader files also, which is wrong. How can I exclude the autoloader files from the coverage report?
Upvotes: 0
Views: 807
Reputation: 35167
When creating the configuration for code coverage, you'll almost always set the 'whitelist' in the phpunit.xml file to only cover your main source files - this also speeds up the test-run, as it's not having to also run code-coverage of all the library files in the vendor/ directory (because that can take a long time).
<filter>
<whitelist processUncoveredFilesFromWhitelist="true"
addUncoveredFilesFromWhitelist="false">
<!-- only collect code coverage in src/**/*.php files -->
<directory suffix=".php">./src</directory>
<exclude>
<!-- directories/files to not cover (within src/) -->
<directory suffix=".php">./src/*/*Bundle/Resources</directory>
<directory suffix=".php">./src/*Bundle/Resources</directory>
<directory suffix=".php">./src/tests/</directory>
</exclude>
</whitelist>
</filter>
Upvotes: 5
Reputation: 8356
Configure a whitelist and do not add the autoloader to it.
Upvotes: 3