【问题标题】:Using PHPUnit Groups使用 PHPUnit 组
【发布时间】:2011-05-30 13:47:16
【问题描述】:

如何在 PHPUnit 中配置测试组?我发现文档有点缺乏......它只是说

<groups> 元素及其 <include><exclude><group> 儿童可用于选择组 来自一组测试的测试 应该(不)运行。

<groups>
  <include>
    <group>name</group>
  </include>
  <exclude>
    <group>name</group>
  </exclude>
</groups>

但是如何将目录/文件添加到这些组中?

【问题讨论】:

    标签: php unit-testing phpunit


    【解决方案1】:

    @group attribute 添加到您的测试方法中。链接文档中的一个简单示例:

    class MyTest extends PHPUnit_Framework_TestCase
    {
        /**
         * @group specification
         */
        public function testSomething()
        {
        }
    
        /**
         * @group regresssion
         * @group bug2204
         */
        public function testSomethingElse()
        {
        }
    }
    

    然后你就可以运行上面文档中提到的PHPUnit了:

    {how you normally run phpunit} --group {GroupName}
    

    【讨论】:

    • 或者您可以像这样按需排除测试组:phpunit --exclude-group regression
    猜你喜欢
    • 2015-07-16
    • 2013-03-22
    • 1970-01-01
    • 2017-11-10
    • 2015-10-16
    • 1970-01-01
    • 2013-05-06
    • 2015-04-04
    • 1970-01-01
    相关资源
    最近更新 更多