Clover PHPUnit Coverage Report Includes Coverage for Unwanted File

I just created CloverPHP in my Jenkins work.

I am using PHPUnit to generate a clover report, and it seems everyone is working separately from the coverage report in which the file is displayed

/usr/share/php/SymfonyComponents/YAML/sfYamlInline.php 

as part of a report. I'm not sure where this comes from, I assume PHPUnit or XDebug include it. Obviously, this is not part of my own code base, so I am not interested in this. This affects the overall metrics obtained in my project. Is there any way to exclude this file from the report?

Thanks a lot, ns

Edit

The answer is to use the phpunit xml configuration file, which may contain a blacklist of filters. I will answer the question correctly after 6 hours (stackoverflow will make me wait 8 hours before answering my question!)

+3
source share
1 answer

After some searches, I found that the answer is to create a configuration file for phpunit, where you can exclude certain files or directories from the code coverage report.

"The <filter> element and its children can be used to customize the blacklist and whitelist for code coverage reports.

<filter>
  <blacklist>
    <directory suffix=".php">/path/to/files</directory>
    <file>/path/to/file</file>
    <exclude>
      <directory suffix=".php">/path/to/files</directory>
      <file>/path/to/file</file>
    </exclude>
      </blacklist>
  <whitelist addUncoveredFilesFromWhitelist="true">
    <directory suffix=".php">/path/to/files</directory>
    <file>/path/to/file</file>
    <exclude>
      <directory suffix=".php">/path/to/files</directory>
      <file>/path/to/file</file>
    </exclude>
  </whitelist>
</filter>

Then call PHPUnit using the flag:

phpunit -c config.xml

More information about the configuration file can be found here:

http://www.phpunit.de/manual/current/en/appendixes.configuration.html

+6

All Articles