开发者

Not run some tests in PHPUnit?

I don't want t开发者_开发技巧o run all the tests sometimes to save time. I know I can comment the tests. But this method isn't elegant. I'm wondering whether there is some simple way to do that.

All advice is appreciated.

Thanks for your time and best regards, Box He


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

Suppose, you need to exclude all the test cases, names of which contain "Foo". Then, use:

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


@group

A test can be tagged as belonging to one or more groups using the @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 for execution based on groups using the --group and --exclude-group switches of the command-line test runner or using the respective directives of the XML configuration file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜