How to skip first N tests in PHPUnit?

心不动则不痛 提交于 2019-12-23 15:37:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!