【问题标题】:test comman works in terminal but not in php测试命令在终端中有效,但在 php 中无效
【发布时间】:2021-10-11 05:22:10
【问题描述】:

当我在终端中执行php artisan test --testsuite=myTestsuite 时,我得到了正确的结果,这就是这个测试套件执行的测试。

但是当我执行php artisan myCommand 时:

然后首先执行 phpunit.xml 中列出的测试套件,然后执行我传递名称的测试套件。

有人知道为什么会这样吗?

【问题讨论】:

  • 请不要发布代码图片,而是将代码添加到代码块中。

标签: laravel phpunit laravel-artisan


【解决方案1】:

要在命令中调用工匠,您需要使用下一个构造:

$this->call('test', ['test suite' => 'MyTestsuite']);

【讨论】:

    【解决方案2】:

    解决了

    shell_exec('php artisan test --testsuite=MyTestsuite')
    

    如果有人找到其他解决方案,请告诉我。谢谢

    【讨论】:

      【解决方案3】:

      您可以使用Artisan 外观,如下所示:

          Artisan::call('test --testsuite=myTestsuite'); 
          $output = Artisan::output();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-07-18
        • 2019-05-07
        • 2020-07-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-15
        • 1970-01-01
        相关资源
        最近更新 更多