我想将 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.
有人可以帮帮我吗?