使用PHPUnit,如何仅测试两个或更多组?

时间:2011-01-26 15:09:29

标签: php testing

在PHPUnit的帮助中,它显示以下内容:

  --group ...              Only runs tests from the specified group(s).
  --exclude-group ...      Exclude tests from the specified group(s).

一组足够容易。这有效:

phpunit --group fast

现在,我无法弄清楚如何使用多个组进行此操作。以下内容对我不起作用:

phpunit --group fast unit   # It believes you want to test unit.php
phpunit --group fast, unit  # It believes you want to test unit.php
phpunit --group "fast unit" # It looks for a single group "fast unit"
phpunit --groups fast, unit # There is no option, groups
phpunit --group fast --group unit   # Only one is honored

欢迎任何关于正确语法的想法。谢谢。

3 个答案:

答案 0 :(得分:28)

使用逗号分隔,不带任何空格。 E.g。

phpunit --group fast,unit

答案 1 :(得分:6)

尝试phpunit --group "fast, unit"phpunit --group fast,unit

命令行参数在空格上分割,因此您必须将值用双引号括起来或省略空格。

答案 2 :(得分:0)

如果您使用phpunit与目录,exclude-group选项需要来第一个目录值,例如: phpunit --exclude-group GroupA,GroupB,GroupC YOUR_DIRECTORY

相关问题