开发者

Mark a PHPUnit test class as to be ignored

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 there a method or annotation that signals Phpunit to not execute this abstract test (but does not mark it as skipped or incomplete)?

Right now Phpunit runs the abstract test class as well and then reports an error that it can not instantiat开发者_StackOverflow中文版e it - which is by language: An abstract class can not be instantiated.


Just add the skip on the setUp():

protected function setUp()
{
    $this->markTestIncomplete();
}


If it is named FooTest rename it to FooTestCase.


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜