ezzatron/phpunit-extensions

此包已被废弃,不再维护。没有建议的替代包。

PHPUnit的扩展,提供额外的功能。

2.0.0 2014-02-17 09:49 UTC

This package is not auto-updated.

Last update: 2020-01-24 14:46:09 UTC


README

PHPUnit的扩展,提供额外的功能。

The most recent stable version is 2.0.0 Current build status image Current coverage status image

安装和文档

参数化测试用例

参数化测试用例允许在多个不同的配置中运行整个PHPUnit测试用例。它们与PHPUnit自带的 数据提供者 类似,但操作级别是在测试用例层面,而不是测试方法层面。

要创建一个参数化测试用例,应扩展 ParameterizedTestCase 类而不是 PHPUnit_Framework_TestCase,并实现所需的方法

use Eloquent\Phpunit\ParameterizedTestCase;

class ExampleTest extends ParameterizedTestCase
{
    public function getTestCaseParameters()
    {
        return array(
            array('Ocelot', 'Lapis lazuli', 'Dandelion'),
            array('Sloth', 'Carbon', 'Conifer'),
        );
    }

    public function setUpParameterized($animal, $mineral, $vegetable)
    {
        // set up...
    }

    public function tearDownParameterized($animal, $mineral, $vegetable)
    {
        // tear down...
    }

    public function testSomething()
    {
        // test...
    }
}

现在,testcase中的每个测试都会在 getTestCaseParameters() 方法中的每个条目上运行一次。