【问题标题】:laravel phpunit how to determine which method to runlaravel phpunit 如何确定运行哪个方法
【发布时间】:2017-05-20 06:34:16
【问题描述】:

我创建了一个 UserTest 类,它将用于测试许多与用户相关的方法,并且每次运行 php vendor\phpunit\phpunit\phpunit 它总是会遍历所有不实用的方法,我想知道是否可以在具体方法。
谢谢

【问题讨论】:

标签: laravel phpunit


【解决方案1】:

刚刚找到我需要的用户--filter 的答案,然后是类的名称,然后是这样的方法的名称

php vendor\phpunit\phpunit\phpunit --filter UserTest::testinput

【讨论】:

    【解决方案2】:

    有两种方法可以做到这一点。要在特定方法上运行,您可以使用过滤器标志。

    vendor/bin/phpunit --filter name_of_the_method
    

    您还可以使用 phpunit.xml 文件将文件组合在一起。寻找标签 testsuite 并创建第二个。

    <testsuite name="API">
        <directory suffix="Test.php">./tests/ApiTests</directory>
    </testsuite>
    

    现在,您可以使用“testsuite”标志仅在该文件夹中运行测试。

    vendor/bin/phpunit --testsuite API
    

    还要注意测试套件目录中的“后缀”。这是指文件必须以什么结尾。您可以通过调整命名约定来过滤将进一步运行测试的文件。

    【讨论】:

      猜你喜欢
      • 2014-11-23
      • 1970-01-01
      • 2018-04-11
      • 2021-12-07
      • 2013-01-08
      • 2018-01-11
      • 2012-05-02
      • 1970-01-01
      相关资源
      最近更新 更多