Skip to content

Instantly share code, notes, and snippets.

@EvanK
Created November 19, 2013 22:45
Show Gist options
  • Save EvanK/7553935 to your computer and use it in GitHub Desktop.
Save EvanK/7553935 to your computer and use it in GitHub Desktop.
Pro tip: PHPUnit's test suite "exclude" nodes don't do wildcard expansion. Took me longer than I'd like to admit figuring this out.
<phpunit>
<testsuites>
<testsuite name="Unit">
<directory>../src/*/Bundle/*Bundle/Tests</directory>
<exclude>src/*/Bundle/*Bundle/Tests/Functional</exclude>
</testsuite>
</phpunit>
<phpunit>
<testsuites>
<testsuite name="Unit Tests">
<directory>../src/*/Bundle/*Bundle/Tests</directory>
<exclude>src/MyProject/Bundle/MyFirstBundle/Tests/Functional</exclude>
<exclude>src/MyProject/Bundle/MySecondBundle/Tests/Functional</exclude>
<exclude>src/MyProject/Bundle/MyThirdBundle/Tests/Functional</exclude>
<exclude>src/MyProject/Bundle/MyNthBundle/Tests/Functional</exclude>
</testsuite>
</testsuites>
</phpunit>
@guiguiboy
Copy link

Thx for sharing.
Also I'd like to add that exclude are ignored if a path is added within the command line.

@MattWohler
Copy link

Someone should probably do something about this lol

@MattWohler
Copy link

So.. maybe someone changed it as this is what my phpunit file looks like, and it works as intended:

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./HCI</directory>
            <exclude>
                <directory suffix=".php">./HCI/*/Routes</directory>
            </exclude>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="./report" charset="UTF-8"
            yui="true" highlight="true"
            lowUpperBound="50" highLowerBound="80" />
    </logging

@idhowardgj94
Copy link

ok, thanks... lol
took me a few hours to figure it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment