问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/27711469/how-to-skip-first-n-tests-in-phpunit