Mark a PHPUnit test class as to be ignored

前端 未结 3 1827
鱼传尺愫
鱼传尺愫 2020-12-18 19:35

I have written an abstract test case class that is to be extended by concrete test case classes.

It extends from the PHPUnit_TestCase.

Is th

相关标签:
3条回答
  • 2020-12-18 20:23

    Just add the skip on the setUp():

    protected function setUp()
    {
        $this->markTestIncomplete();
    }
    
    0 讨论(0)
  • 2020-12-18 20:25

    If it is named FooTest rename it to FooTestCase.

    0 讨论(0)
  • 2020-12-18 20:26

    Assuming you want to exclude the file name TestCase.php. As in my case I use this class as an abstract to all my test classes which itself extends PHPUnit_Framework_TestCase.

    Solution: add this to your phpunit.xml

    <testsuites>
        <testsuite name="BLABLA">
            <directory suffix=".php">./tests</directory>
            <exclude>./tests/TestCase.php</exclude>
        </testsuite>
    </testsuites>
    

    My TestCase.php example:

    <?php
    namespace Foo\Bar\Tests;
    
    use Mockery as M;
    use PHPUnit_Framework_TestCase as PHPUnit;
    
    /**
     * Class TestCase is the Parent test class that every test class must extend from.
     */
    class TestCase extends PHPUnit
    {
    
        public function __construct()
        {
            parent::__construct();
        }
    
    //...
    
    0 讨论(0)
提交回复
热议问题