所以我想从我的Testsuite中排除一个directoy,就像这样:
<testsuite name="PHPUnitWillKillMe">
<directory>src/*/Bundle/*/*Bundle/Tests</directory>
<exclude>src/*/Bundle/*/*Bundle/Tests/Controller/</exclude>
</testsuite>
应该测试除控制器之外的所有东西。
问题是,它不起作用。 PHPUnit仍在src /中运行所有测试/束// * Bundle / Tests / Controller /我跑的时候
phpunit --testsuite PHPUnitWillKillMe
任何想法?
最好的祝福!
我测试过的PHPUnit版本是3.7.21和3.7.28。
我在我的Symfony演示项目上测试了它 Bundles
表明这是你正在使用的)我有同样的问题。这似乎是两个问题的结合。首先,运行PHPUnit(PHPUnit 3.7.19)的一个已知错误 -c
要么 --config
选项:
https://github.com/sebastianbergmann/phpunit/issues/928
在其他地方运行并使用--config指定配置文件时,排除将停止工作。
第二, exclude
当有任何globbing时,指令似乎忽略/失败(*
)在路径中,所以通过删除globbing,它对我有用:
<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>
就是这样 只要 我发现排除测试的方式 MyBundle
按要求。全球化了 不 为...工作 exclude
。但是,这意味着你必须添加更多 exclude
指令,因为有想要忽略的文件夹。
可能相关的gihub问题:
https://github.com/sebastianbergmann/phpunit/pull/573
[...]这个修复程序登陆4.0版本,因为它打破了向后兼容性。
- 解决方案#1:删除路径中的任何globbing
- 解决方案#2:升级到PHPUnit v4。*(未经我自己测试,请参阅注释,并未解决问题
exclude
带有globbing的路径)
刚刚有类似的问题,phpunit对群组有很好的支持:
...
--filter <pattern> Filter which tests to run.
--group ... Only runs tests from the specified group(s).
--exclude-group ... Exclude tests from the specified group(s).
--list-groups List available test groups.
...
你做的是
/**
* @group nonRunnableGroupName
*/
public function testSomething()
{ /* test here */ }
并运行测试
$ phpunit -c /src --exclude-group nonRunnableGroupName