Laravel 8 not running newly created tests, and not picking up deleted tests

Viewed 2295

I'm just getting started with the Laravel 8 testing suite and have opted to create a feature test for my account creation process. I've ran php artisan make:test AccountCreation and have written the first test case as a function, however, when I run php artisan test it's not picking up my feature tests, why?

Equally, if I try to delete the default example test, I get an error telling me that the test can't be found? What am I missing?

tests/Feature/AccountCreation.php

<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class AccountCreation extends TestCase
{
    /**
     * A basic feature test example.
     *
     * @return void
     */
    public function test_creates_user_account_successfully()
    {
        $response = $this->post('/api/account/create');
        $response->assertStatus(201);
    }
}

Is there a special command I need to run for Laravel to pick up these tests?

no tests

2 Answers

Because you should append 'Test' to your test class, because PHPUnit will check all classes end with Test, so change:

class AccountCreation extends TestCase { ...

to:

class AccountCreationTest extends TestCase { ...

Don't forget to change your class file name.

/** @test */

Put this before every test. It worked for me.

Related