使用 PHPUnit 组

发布于 2024-10-09 10:54:46 字数 400 浏览 0 评论 0原文

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

元素及其 <包含><排除> 孩子们可以用来选择组 一组测试中的测试 应该(不)运行。

<前><代码><组>; <包括> <组>名称 <排除> <组>名称

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

How can I configure groups of tests in PHPUnit? I find the docs a little lacking ... it just says

The <groups> element and its
<include>, <exclude>, and <group>
children can be used to select groups
of tests from a suite of tests that
should (not) be run.

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

But how can I add directories/files into these groups?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无边思念无边月 2024-10-16 10:54:46

添加 @group 属性< /a> 您的测试方法。链接文档中的一个简单示例:

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}

Add the @group attribute to your test methods. A simple example from the linked docs:

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

    /**
     * @group regresssion
     * @group bug2204
     */
    public function testSomethingElse()
    {
    }
}

Then you can run PHPUnit mentioned in the documentation above:

{how you normally run phpunit} --group {GroupName}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文