首页 > 解决方案 > 我必须在 laravel 中使用 phpunit 运行测试时按 Enter

问题描述

我必须在 Laravel 5.7 中使用 phpunit 运行测试时按 Enter 键。

在每次测试中,我都会收到以下消息:

1) Tests\Feature\DepartmentsTest::a_admin_can_create_a_department Mockery\Exception\BadMethodCallException: Received Mockery_1_Illuminate_Console_OutputStyle::askQuestion(),但未指定预期

通过将以下设置为false,错误消失:

public $mockConsoleOutput = false;

之后,窗口挂起运行测试套件,我需要按 Enter 键运行测试。

我该如何解决?

我正在使用 Windows 10 + PHPUnit 7.5.1 和 Laravel 5.7.19

提前致谢!

/** @test */
public function a_admin_can_create_a_department()
    {

        // $this->withoutExceptionHandling();

        $attributes = [
            'description' => 'Service',
            'accessible_by_depart' => true
        ];

        $this->post('/tools/api/storeDepartment', $attributes);

        $this->assertDatabaseHas('departments', $attributes);
    }

标签: laravelwindows-10phpunitmockery

解决方案


这为我解决了问题 https://stackoverflow.com/a/48303288/2171254

之后,我不需要这条线public $mockConsoleOutput = false;

问候


推荐阅读