dstewart101's avatar

can't add more than one test per file

I have this test file:

<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Gameworld;

class SearchForGameworld extends TestCase
{
    use DatabaseMigrations;

    public function test_can_search_and_find_a_gameworld()
    {
        $gameworld = factory(Gameworld::class)->create([
            'name' => 'DS Test 1'
        ]);


        $this->visit('/game/search')
                 ->see('Search For Game')
                 ->type('DS', '#gameworld_name')
                 ->press('Search')    
                 ->seePageIs('/game/search')
                 ->see('Game Search Results')
                 ->see('DS Test 1');
    }
}

All tests pass.

OK (1 test, 7 assertions)

I add another test so the file now looks like this:

<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Gameworld;

class SearchForGameworld extends TestCase
{
    use DatabaseMigrations;

    public function test_can_search_and_find_a_gameworld()
    {
        $gameworld = factory(Gameworld::class)->create([
            'name' => 'DS Test 1'
        ]);


        $this->visit('/game/search')
                 ->see('Search For Game')
                 ->type('DS', '#gameworld_name')
                 ->press('Search')    
                 ->seePageIs('/game/search')
                 ->see('Game Search Results')
                 ->see('DS Test 1');
    }

    public function join_link_is_displayed_for_non_logged_in_user()
    {
        $gameworld = factory(Gameworld::class)->create([
            'name' => 'DS Test 1'
        ]);


        $this->visit('/game/search')
                 ->see('Search For Game')
                 ->type('DS', '#gameworld_name')
                 ->press('Search')    
                 ->seePageIs('/game/search')
                 ->see('Game Search Results')
                 ->see('DS Test 1')
                 ->see('Join');
    }
}

I get the same test result:

OK (1 test, 7 assertions)

Is there any reason my second test isn't picked up? Thanks.

0 likes
2 replies
jaydeluca's avatar
Level 8

you need to either start the name of the test with "test" so

public function test_join_link_is_displayed_for_non_logged_in_user()

or add a doc block before the test like this:

/** @test */
public function join_link_is_displayed_for_non_logged_in_user()
4 likes
dstewart101's avatar

Of course! Argh! Thanks very much for pointing that out. DS

Please or to participate in this conversation.