所以我想像这样从我的Testsuite中排除Directoy:
<testsuite name="PHPUnitWillKillMe">
<directory>src/*/Bundle/*/*Bundle/Tests</directory>
<exclude>src/*/Bundle/*/*Bundle/Tests/Controller/</exclude>
</testsuite>
除 Controller 外的所有物品都应进行测试。
问题是,它不起作用。当我运行时,PHPUnit仍在src//Bundle//** Bundle/Tests/Controller/中运行所有测试
phpunit --testsuite PHPUnitWillKillMe
任何的想法?
最好的祝福!
我测试的PHPUnit版本是3.7.21和3.7.28。
最佳答案
我在Symfony演示项目上对其进行了测试(Bundles
表示这就是您正在使用的),但我遇到了同样的问题。这似乎是两个问题的结合。首先,使用-c
或--config
选项运行PHPUnit(PHPUnit 3.7.19)存在一个已知的错误:
https://github.com/sebastianbergmann/phpunit/issues/928
When running it elsewhere and specifying the config file using --config, the exclude would however stop working.
其次,当路径中存在任何通配符(
exclude
)时,*
指令似乎会忽略/失败,因此通过删除通配符,它对我有用:<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
,globbing的不起作用,不起作用。但是,这意味着您必须添加与要忽略的文件夹一样多的exclude
指令。可能的相关Gihub问题:
https://github.com/sebastianbergmann/phpunit/pull/573
[...] this fix lands in the 4.0 release as it breaks backwards compatibility.
exclude
路径问题)关于php - PHPUnit TestSuite排除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22645986/