首页 > 解决方案 > “”目录不存在 - Laravel 7 + PhpUnit

问题描述

我开始测试 laravel 7 应用程序。我创建了一个简单的测试:

namespace Tests\Unit;

use Tests\TestCase;

class LoginTest extends TestCase
{     

    /** @test */
    public function user_login() {
      $response = $this->get('/');
      $response->assertStatus(200);
    }
}

但是,当我运行时vendor/bin/phpunit,我收到此错误: 1) Tests\Feature\LoginTest::user_login Symfony\Component\Finder\Exception\DirectoryNotFoundException: The "" 目录不存在。

当我改变这条线

use Tests\TestCase;

use PHPUnit\Framework\TestCase;

我得到一个不同的错误:

1) Tests\Unit\LoginTest::user_login 错误:调用未定义的方法 Tests\Unit\LoginTest::get()

我做错了什么?有人可以帮我弄清楚吗?

非常感谢。

标签: phpunitlaravel-7

解决方案


推荐阅读