Exclusion of a PHP Interface from PHPUnit Code Coverage

I have a PHPUnit test that tests a class called HelpTokenizerTest. This class implements TokenizerInterface. For some strange reason, I can't exclude TokenizerInterface from code coverage.

It appears in code coverage reports that are not covered, despite using @codeCoverageIgnore or even @ codeCoverageIgnoreStart / End.

Any ideas?

I do not want the interface to be included in my test coverage, as it does nothing. What is the point of testing the interface.

+3
source share
2 answers

When using phpunit.xml, you can configure filters to exclude files with specific names, in particular folders or with a specific extension.

.

:

<testsuite name="Application Test Suite">
    <directory>./application/</directory>
</testsuite>

<filter>
    <blacklist>
        HERE
    </blacklist>
       or alternatively
    <whitelist>
        <directory suffix=".php">../library/</directory>
        <directory suffix=".php">../application/</directory>
        <exclude>
            AND HERE
            <directory suffix=".phtml">../application/</directory>
        </exclude>
    </whitelist>
</filter>

+2

@codeCoverageIgnore , 100% 0/0.

<?php // @codeCoverageIgnoreStart 
interface MyInterface
{
    public function myfunction();
}

, .

PHPUnit github: https://github.com/sebastianbergmann/phpunit/issues/497

+2

All Articles