Not running some tests in PHPUnit?

I don’t want to run all the tests sometimes to save time. I know I can comment on the tests. But this method is not elegant. I am wondering if there is an easy way to do this.

All tips are welcome.

Thanks for your time and best wishes, Box He

+4
source share
2 answers

@group

A test can be marked as belonging to one or more groups using an @group annotation like this

class MyTest extends PHPUnit_Framework_TestCase { /** * @group specification */ public function testSomething() { } /** * @group regresssion * @group bug2204 */ public function testSomethingElse() { } } 

Tests can be selected to run on a group basis using the -group and --exclude -group switches for a test runner on the command line or using the appropriate XML configuration file directives.

+10
source

command line phpunit command line testing has the argument --filter , which is a regular expression to match the executed test case names.

Suppose you want to exclude all test cases whose names contain "Foo". Then use:

 --filter /^(?:(?!Foo).)*$/ 
+8
source

All Articles