Exclude base directory from PHPUnit code scope

How to exclude base directories from the PHPUnit Code shell?

This is my phpunit.xml

<?xml version="1.0" encoding="UTF-8"?> <phpunit bootstrap="include.php" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false"> <testsuite name="MyProject"> <directory>classes/*</directory> </testsuite> <logging> <log type="coverage-html" target="../reports/coverage" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/> <log type="coverage-xml" target="../reports/coverage.xml"/> <log type="test-xml" target="../reports/logfile.xml" logIncompleteSkipped="false"/> <log type="testdox-html" target="../reports/testdox.html"/> <log type="testdox-text" target="../reports/testdox.txt"/> </logging> </phpunit> 

When it is displayed, it includes all the basic directories, such as:

 c:\work\some\path\MyProject 

How can I only include ...\MyProject\* in the output of Code Coverage?

+7
source share
1 answer

There is no description of your project layout in your answers, but I assume that you are looking for:

Include and exclude files to cover code

This allows you to specify a whitelist of files that PHPUnit will be interested in when creating code coverage.

Anything that is not in this whitelist will not be displayed in the report.

To do this, add the following top level:

 <filter> <whitelist processUncoveredFilesFromWhitelist="true"> <directory suffix=".php">.../MyProject/</directory> </whitelist> </filter> 
+5
source

All Articles