How to skip tests in PHPunit?

后端 未结 3 585
天命终不由人
天命终不由人 2021-01-31 13:00

I am using phpunit in connection with jenkins, and I want to skip certain tests by setting the configuration in the XML file phpunit.xml

I know that I can

3条回答
  •  不知归路
    2021-01-31 13:40

    Sometimes it's useful to skip all tests from particular file based on custom condition(s) defined as php code. You can easily do that using setUp function in which makeTestSkipped works as well.

    protected function setUp()
    {
        if (your_custom_condition) {
            $this->markTestSkipped('all tests in this file are invactive for this server configuration!');
        }
    }
    

    your_custom_condition can be passed via some static class method/property, a constant defined in phpunit bootstrap file or even a global variable.

提交回复
热议问题