小编Dan*_*bov的帖子

Laravel 5.4上的示例PHPUnit测试失败,带有404

我可以通过link:localhost:8888/streaming_statistic/public在Laravel 5.4上创建我的项目

我有一个测试:

<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class ApiTest extends TestCase
{
    public function testBasicTest()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
}
Run Code Online (Sandbox Code Playgroud)

我用命令运行所有测试

./vendor/bin/phpunit
Run Code Online (Sandbox Code Playgroud)

但结果是:

PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 222 ms, Memory: 12.25MB

There was 1 failure:

1) Tests\Feature\ApiTest::testBasicTest
Expected status code 200 but received 404.
Failed asserting that false is true.

/Applications/MAMP/htdocs/streaming_statistic/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:56
/Applications/MAMP/htdocs/streaming_statistic/tests/Feature/ApiTest.php:16

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Run Code Online (Sandbox Code Playgroud)

我可以打开这个页面http:// localhost:8888/streaming_statistic/public …

php testing phpunit laravel-5 laravel-5.4

8
推荐指数
1
解决办法
5602
查看次数

标签 统计

laravel-5 ×1

laravel-5.4 ×1

php ×1

phpunit ×1

testing ×1