samedi 3 novembre 2018

Laravel Unit Testing showing "Expected status code 200 but received 404."

I am facing one problem, and I am not getting why is this happening. please help me on this, Thanks in advance.

So I am using laravel 5.5. and I am not using .env I have set all value in the config file.

there is basic route.

Route::get("/", function(){
    return "Hello";
});

In browser it is coming fine. no issue, Now I want to use unit testing, for that there is inbuild unit testing class. So I am running this phpunit and I am getting this.

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

this is my unit testing class

namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase{
    public function testBasicTest(){
        $response = $this->get('/');
        $response->assertStatus(200);
    }
}

This is my phpunit.xml env

<php>
    <env name="APP_ENV" value="testing"/>
    <env name="CACHE_DRIVER" value="array"/>
    <env name="SESSION_DRIVER" value="array"/>
    <env name="QUEUE_DRIVER" value="sync"/>
</php>

Please help me on this.

Aucun commentaire:

Enregistrer un commentaire