Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PHPUnit, How Do You Test Only Two or More Groups?

Tags:

php

testing

In PHPUnit's help it displays the following:

  --group ...              Only runs tests from the specified group(s).
  --exclude-group ...      Exclude tests from the specified group(s).

Easy enough for one group. This works:

phpunit --group fast

Now, I can't quite figure out how to do this with more than one group. The following is not working for me:

phpunit --group fast unit   # It believes you want to test unit.php
phpunit --group fast, unit  # It believes you want to test unit.php
phpunit --group "fast unit" # It looks for a single group "fast unit"
phpunit --groups fast, unit # There is no option, groups
phpunit --group fast --group unit   # Only one is honored

Any thoughts on the correct syntax would be welcome. Thank you.

like image 952
bitsoflogic Avatar asked Jan 26 '11 15:01

bitsoflogic


People also ask

What is PHPUnit testing?

PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit design for unit testing systems that began with SUnit and became popular with JUnit. Even a small software development project usually takes hours of hard work.

What is the PHPUnit XML configuration file used to organize tests?

The <testsuite> Element.

What is the purpose of PHPUnit?

PHPUnit is a framework independent library for unit testing PHP. Unit testing is a method by which small units of code are tested against expected results. Traditional testing tests an app as a whole meaning that individual components rarely get tested alone.

What is stub in PHPUnit?

Stub. Stubs are used with query like methods - methods that return things, but it's not important if they're actually called. $stub = $this->createMock(SomeClass::class); $stub->method('getSomething') ->willReturn('foo'); $sut->action($stub);


2 Answers

Use comma separation without any whitespace. E.g.

phpunit --group fast,unit
like image 114
borrible Avatar answered Oct 08 '22 18:10

borrible


Try phpunit --group "fast, unit" or phpunit --group fast,unit.

Command-line parameters are split on space, so you have to either wrap the value in double quotes or omit spaces.

like image 37
Adam Lear Avatar answered Oct 08 '22 20:10

Adam Lear