How can I ignore a test method in phpunit without modifying its content? How can I ignore a test method in phpunit without modifying its content? symfony symfony

How can I ignore a test method in phpunit without modifying its content?


You can tag the test with a group annotation and exclude those tests from a run.

/** * @group ignore */public void ignoredTest() {    ...}

Then you can run the all the tests but ignored tests like this:

phpunit --exclude-group ignore


The easiest way would be to just change the name of the test method and avoid names starting with "test". That way, unless you tell PHPUnit to execute it using @test, it won't execute that test.

Also, you could tell PHPUnit to skip a specific test:

<?phpclass ClassTest extends PHPUnit_Framework_TestCase{         public function testThatWontBeExecuted()    {        $this->markTestSkipped( 'PHPUnit will skip this test method' );    }    public function testThatWillBeExecuted()    {        // Test something    }}


You can use the method markTestIncomplete() to ignore a test in PHPUnit:

<?phprequire_once 'PHPUnit/Framework.php';class SampleTest extends PHPUnit_Framework_TestCase{    public function testSomething()    {        // Optional: Test anything here, if you want.        $this->assertTrue(TRUE, 'This should already work.');        // Stop here and mark this test as incomplete.        $this->markTestIncomplete(            'This test has not been implemented yet.'        );    }}?>