【问题标题】:PHPUnit Testing LaravelPHP 单元测试 Laravel
【发布时间】:2020-09-03 23:08:46
【问题描述】:

我无法在 PHPUnit 中解决这个问题。在 Postman 中它运行良好,但在 PHPUnit 中出现错误。

class MyPageTakumoiTest extends TestCase
{
    protected $api = "/api/my_page_takumoi/2";

    public function testUpdate()
    {

        $response = $this->json('PUT', $this->api, [
            'family_name' => 'new kk',
        ]);

        $response->assertStatus(200);

    }
}

Expected status code 200 but received 500.
Failed asserting that 200 is identical to 500.

【问题讨论】:

  • 你有一些日志吗?状态 500 是一般错误状态...

标签: laravel phpunit


【解决方案1】:

您可以在测试开始时使用它来获得更好的异常:

$this->withoutExceptionHandling();

【讨论】:

  • 这不是答案,但它就像一个答案。谢谢。
猜你喜欢
  • 2017-10-26
  • 1970-01-01
  • 2018-12-17
  • 2019-08-01
  • 1970-01-01
  • 2020-03-09
  • 2016-08-26
  • 2021-11-16
  • 1970-01-01
相关资源
最近更新 更多