vendredi 31 juillet 2020

Basic Test is failing on Laravel 7

I'm trying to code my first test.

I tried to run the out-the-box test:

<?php

namespace Tests\Feature;

use Tests\TestCase;

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
}

with

php artisan test

But I get:

➜  acc git:(master) ✗ php artisan test

   PASS  Tests\Unit\ExampleTest
  ✓ basic test

   FAIL  Tests\Feature\ExampleTest
  ✕ basic test

  Tests:  1 failed, 1 passed

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

  at tests/Feature/ExampleTest.php:18
    14|     public function testBasicTest()
    15|     {
    16|         $response = $this->get('/');
    17| 
  > 18|         $response->assertStatus(200);
    19|     }
    20| }
    21| 

When I go to chrome to : http://localhost:8000 I get a 200.

Why is it happening ?

Aucun commentaire:

Enregistrer un commentaire