PHPUnit TestSuite Exclude
php, phpunit, unit-testing
Solution
I tested it on my Symfony demo project (the `Bundles` suggests that this is what you are using) and I have the same issue. It seems to be a combination of two problems. First, there is a known bug with running PHPUnit (PHPUnit 3.7.19) with the `-c` or `--config` option:
https://github.com/sebastianbergmann/phpunit/issues/928
When running it elsewhere and specifying the config file using --config, the exclude would however stop working.
Second, the `exclude` directive seems to ignore / fail when there is any globbing (`*`) in the path, so by removing the globbing, it worked for me:
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
<exclude>../src/Blah/MyBundle/Tests/Controller/</exclude>
</testsuite>
</testsuites>
It's the only way I found to exclude the Tests in `MyBundle` as required. The globbing did not work for the `exclude`. But then, it means you have to add as many `exclude` directives as there are folders you want to ignore.
Probable related gihub issue: https://github.com/sebastianbergmann/phpunit/pull/573
[...] this fix lands in the 4.0 release as it breaks backwards compatibility.
- Solution #1: remove any globbing in your paths
- Solution #2: Upgrade to PHPUnit v4.* (not tested by myself, see comments, doesn't solve the problem of `exclude` paths with globbing)
Problem
so I would like to exclude a directoy from my Testsuite just like this: ``` <testsuite name="PHPUnitWillKillMe"> <directory>src/*/Bundle/*/*Bundle/Tests</directory> <exclude>src/*/Bundle/*/*Bundle/Tests/Controller/</exclude> </testsuite> ``` Everything except for the Controllers should be tested. The thing is, it does not work. PHPUnit still runs all the tests in src//Bundle//*Bundle/Tests/Controller/ when I run ``` phpunit --testsuite PHPUnitWillKillMe ``` Any idea? Best Regards! PHPUnit Version I tested this were 3.7.21 and 3.7.28.