Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip first N tests in PHPUnit?

The scenario: run a huge batch of tests with PHPUnit and some test (say 537 of 1544) fails after many minutes. The change is small and unlikely to effect the previous tests, I'd like to be able to skip the first 536 tests doing something like this to "pick up where I left off":

phpunit --skip=536

Of course I will run all tests eventually, but right now, I don't want to have to wait many minutes to get back to the broken test(s). I know I can run a single suite but that is tedious/unhelpful if several dozen suites remain to be tested.

Is there a way? Or something even close?

like image 973
Dwayne Towell Avatar asked Oct 31 '22 12:10

Dwayne Towell


1 Answers

You can use the --filter option to select which tests that you want to run. There is also the --testsuite option which you can use to specify. Both of these options take a pattern parameter that is used to select the tests that you are running.

The --testsuite option does require that you have the test suites created in a phpunit.xml file in order to work.

There is also the @group annotation that can be used in your tests and then would be able to use --group and --exclude-group to either include the group or not respectively.

like image 55
Schleis Avatar answered Nov 15 '22 05:11

Schleis