简体   繁体   English

如何从排除列表中运行phpunit测试?

[英]How can i run phpunit tests from excluded list?

i have this configuration in phpunit.xml . 我在phpunit.xml有此配置。 My concern is that I don't want to run a test when phpuint command is executed. 我担心的是,我不想在执行phpuint命令时运行测试。

<testsuite name="Unit">
    <directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
    <directory suffix="Test.php">./tests/Feature</directory>
    <exclude>./tests/Feature</exclude>
</testsuite>

i need to run Feature test separatly, Is it possible ? 我需要分别运行功能测试,这可能吗?

I do the same of limiting the tests that are being run - the larger set only runs when I specifically run all the tests, and less than half for a normal, quick-run. 我做同样的事情来限制正在运行的测试-较大的设置仅在我专门运行所有测试时才运行,而对于正常的快速运行而言,只有不到一半的运行。

The trick is to add @group annotations to the test sources (on a class or method basis) - so, for example: 技巧是将@group批注添加到测试源(基于类或方法)-因此,例如:

/** 
 * @group feature
 * @group large
 */
public function testFeatureThatTakesTime() {}

Now, if you run vendor/bin/phpunit --exclude-group feature ./tests/ it will not run that test. 现在,如果您运行vendor/bin/phpunit --exclude-group feature ./tests/ ,它将不会运行该测试。 I have that, and some other command-line parameters in a shell script, and there are other ways for me to run all of my tests. 我在外壳程序脚本中有该脚本和其他一些命令行参数,还有其他方法可以运行所有测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM