Running test not picking the 2nd test
This test feature has 2 tests:
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class LocationsTest extends TestCase
{
use WithFaker, RefreshDatabase;
/** @test */
public function a_user_can_create_a_location()
{
$this->withoutExceptionHandling();
$attributes = [
'name' => $this->faker->sentence,
'description' => $this->faker->paragraph
];
$this->post('/locations', $attributes)->assertRedirect('/locations');
$this->assertDatabaseHas('locations', $attributes);
$this->get('/locations')->assertSee($attributes['name']);
}
/** test */
public function a_location_requires_a_name()
{
$this->post('/locations', [])->assertSessionHasErrors('name');
}
}
but when I run the test, it's not picking the 2nd one called a_location_requires_a_name().
PASS Tests\Feature\LocationsTest
✓ a user can create a location
Tests: 1 passed
Time: 2.45s
The annotation is wrong, it should be @test
/** @test */
public function a_location_requires_a_name()
{
$this->post('/locations', [])->assertSessionHasErrors('name');
}
Or you can prefix the test method name with test_, e.g.
public function test_a_location_requires_a_name()
{
$this->post('/locations', [])->assertSessionHasErrors('name');
}
@tykus What a shame! 🤦♂️
Thanks a lot!
Please or to participate in this conversation.