@group

测试可以用 @group 标注来标记为属于一个或多个组,就像这样:

  1. class MyTest extends PHPUnit_Framework_TestCase
  2. {
  3. /**
  4. * @group specification
  5. */
  6. public function testSomething()
  7. {
  8. }
  9.  
  10. /**
  11. * @group regresssion
  12. * @group bug2204
  13. */
  14. public function testSomethingElse()
  15. {
  16. }
  17. }

测试可以基于组来选择性的执行,使用命令行测试执行器的 —group and —exclude-group 选项,或者使用对应的 XML 配置文件指令。