Pierrick Rambaud
Pierrick Rambaud

Reputation: 2364

Run a single test with phpUnit

I'm currently introducing tests in my Symfony app. Some of them are failing and it takes ages to run them all.

Is it possible to run a single test with the simpl-phpunit command ?

I already tested :

with the namespace of my test but ended up with

./vendor/bin/simple-phpunit App\tests\Controller\DefaultControllerTest

Cannot open file "ApptestsControllerDefaultControllerTest.php".

and with the relative path to my Test, ut it leads to:

./vendor/bin/simple-phpunit tests/Controller/DefaultControllerTest

Cannot open file "tests/Controller/DefaultControllerTest.php".

Upvotes: 2

Views: 4457

Answers (1)

T. Altena
T. Altena

Reputation: 811

Can you try running the full phpunit executable?

./vendor/bin/phpunit tests/Controller/DefaultControllerTest

The second version of the command should work. You can go even more fine-grained than testfiles by putting an @group in the PHPdoc part to run individual functions like so:

/**
 * A basic test example.
 * @group test
 * @return void
 */

public function testHomePage()
{
    // basic get test
    $this->get('')->assertStatus(200)
        ->assertSee('Home');
}

run it with

./vendor/bin/phpunit --group=test

Upvotes: 7

Related Questions