Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PHPUnit Groups

How can I configure groups of tests in PHPUnit? I find the docs a little lacking ... it just says

The <groups> element and its <include>, <exclude>, and <group> children can be used to select groups of tests from a suite of tests that should (not) be run.

<groups>
  <include>
    <group>name</group>
  </include>
  <exclude>
    <group>name</group>
  </exclude>
</groups>

But how can I add directories/files into these groups?

like image 261
Jiew Meng Avatar asked Dec 25 '10 03:12

Jiew Meng


1 Answers

Add the @group attribute to your test methods. A simple example from the linked docs:

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

    /**
     * @group regresssion
     * @group bug2204
     */
    public function testSomethingElse()
    {
    }
}

Then you can run PHPUnit mentioned in the documentation above:

{how you normally run phpunit} --group {GroupName}
like image 174
David Harkness Avatar answered Sep 29 '22 02:09

David Harkness