I want to execute few selected test cases from my class of multiple test cases using php unit with ease.
As my 1-2 test cases are failing from bunch of test cases and also finding difficult to execute whole test suite again for these two, is there any method without adding comment to the others or copying these two methods in different suite.
Thanks to all in advance
You may run single test cases or single test classes from your suites using the --filter cli option:
--filter <pattern> Filter which tests to run.
--filter
runs tests whose name matches the given pattern. The pattern can be either the name of a single test or a regular expression that matches multiple test names.
Take the following example test class BlaTest
containing test cases testSame
and testElse
in file BlaTest.php
:
// BlaTest.php
<?php
class BlaTest extends PHPUnit_Framework_TestCase {
public function testSame() { $this->assertSame(1,1); }
public function testElse() { $this->assertSame(1,1); }
}
BlaTest
This filter matches the test class name.
$ phpunit --filter BlaTest
BlaTest
This filter matches the test case name, then indicates to run this filter across file BlaTest.php.
$ phpunit --filter testSame BlaTest.php