【发布时间】:2010-10-25 02:34:31
【问题描述】:
我想将 PHPUnit 集成到我的框架中。 我的意思是,在运行测试之前,我必须在开始时进行一些初始化,比如设置自动加载。
我想使用cli测试运行器,如果我理解正确的话,我必须创建一个类,它有一个静态函数suite(),它返回一个PHPUnit_Framework_TestSuite的实例,并向这个套件添加测试,如http://www.phpunit.de/manual/current/en/textui.html 所述。
到目前为止,我想出了:
class MyTestFW {
public static function suite() {
// Do framework initialization here
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTest(new SimpleTest());
// Add more tests
return $suite;
}
}
SimpleTest 是一个非常基本的测试类,它扩展了 PHPUnit_Framework_TestCase。 当我运行“phpunit MyTestFW”时,我总是得到:
PHPUnit 3.3.16 by Sebastian Bergmann.
E
Time: 0 seconds
There was 1 error:
1) (SimpleTest)
RuntimeException: PHPUnit_Framework_TestCase::$name must not be NULL.
有人能帮帮我吗?
【问题讨论】:
标签: php frameworks phpunit