如何跳过PHPUnit中的前N个测试

如何跳过PHPUnit中的前N个测试

本文介绍了如何跳过PHPUnit中的前N个测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:使用PHPUnit运行大量测试,并且某些测试(例如1544中的537)在几分钟后失败.更改很小,不太可能影响以前的测试,我希望能够跳过前536个测试,执行以下操作以从我离开的地方收拾":

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?

推荐答案

您可以使用--filter选项选择要运行的测试.您还可以使用--testsuite选项进行指定.这两个选项都带有一个模式参数,该参数用于选择您正在运行的测试.

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.

--testsuite选项确实需要您在phpunit.xml文件中创建测试套件才能正常工作.

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

还有 @group注释可以在您的测试中使用,然后可以分别使用--group--exclude-group来包括或不包括该组.

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.

这篇关于如何跳过PHPUnit中的前N个测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 18:35