lundi 2 avril 2018

No error output in json http tests

I made my first api test to test my authentication.

Code of my test method:

public function testAuthentication()
{
    $user = factory(User::class)->make();
    $response = $this->json('POST', '/api/auth/login', [
        'email' => 'admin@something.com',
        'password' => 'Zz123456',
    ]);

    $response
        ->assertStatus(200)
        ->assertJson([
            'access_token' => '123'
        ]);
}

When I run tests, I see not error output, just status code of request:

root@5704f5d03fbb:/var/www# vendor/bin/phpunit 
PHPUnit 7.0.3 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 1.25 seconds, Memory: 18.00MB

There was 1 failure:

1) Tests\Feature\AuthenticationTest::testAuthentication
Expected status code 200 but received 500.
Failed asserting that false is true.

/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:109
/var/www/tests/Feature/AuthenticationTest.php:22

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

I want to see bad response on every failed test. How to make it automatically print response on failed tests? I can make $response-dump() manually, but it is not good to change tests code on every fail to find an error.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JboQZL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire