phpunit

How to exclude directories from phpunit coverage report


I tried the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
    <testsuites>
      <testsuite name="My Test Suite">
         <directory suffix=".php">Test/Case/Model</directory>
        <exclude>Test/Case/Model/Behavior</exclude>
      </testsuite>
    </testsuites>
</phpunit>

but it does not exclude the behaviour from coverage report. How to exclude these directories or files from the coverage report?


Solution

  • Refer to the exclude element phpunit documentation.

    Here is an example phpunit.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <phpunit>
      <filter>
        <whitelist>
          <directory suffix=".php">../</directory>
          <exclude>
            <file>../ext_emconf.php</file>
            <directory suffix=".php">../tests</directory>
          </exclude>
        </whitelist>
      </filter>
    </phpunit>