简体   繁体   中英

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".

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM