3

I have my PHPUnit setup and coverage report working fine without a white list filter. Once I add one however, the report seems to only partially generate as if PHPUnit quit unexpectedly. I do not get any errors or warnings.

My configuratoon looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./bootstrap.php"
         colors="true">
    <testsuites>
        <testsuite name="...">
            <testsuite name="...">
                <directory>./path/to/suite</directory>
            </testsuite>
            <testsuite name="...">
                <directory>./path/to/suite2</directory>
            </testsuite>
            <testsuite name="...">
                <directory>./path/to/suite3</directory>
            </testsuite>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory suffix=".php">../path/to/files</directory>
        </whitelist>
    </filter>

    <logging>
        <log type="coverage-html" target="log/" charset="UTF-8" yui="true" />
    </logging>
</phpunit>

Any idea on what could be going wrong?

2 Answers 2

2

Turns out there was some script halting procedural code in the files I was white listing.

Sign up to request clarification or add additional context in comments.

1 Comment

yes, a hard DIE() or EXIT; in php code will stop PHPunit coverage reports.
1

Sorry for digging up an old one but I googled for phpunit code coverage not working and this one showed up.

I let code coverage just run it's course (think xdebug is used for it) and it was fine for a while.

Then when I created a new test it suddenly stopped working, code that ran was marked as not covered.

The test classes I created with phpunit: phpunit-skelgen --test

That one creates coverage annotations like: @covers MyClass::someMethod

Removing them solved it for me, xdebug now was used again and suddenly had 100% coverage.

One remark on coverage; Just calling a method once covers it in the report but mostly cannot be considered as covered. Calling it with null values and invalid values covers it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.