作者:我是爱琴白痴_935 | 来源:互联网 | 2023-05-17 05:14
IdliketointegratePHPUnittomyframework.Bythis,ImeanthatIhavetodosomeinitializingi
I'd like to integrate PHPUnit to my framework. By this, I mean that I have to do some initializing in the beginning, like setting up autoloads, before I'd run the tests.
我想将PHPUnit集成到我的框架中。通过这个,我的意思是我必须在开始时做一些初始化,比如在我运行测试之前设置自动加载。
I'd like to use the cli test runner, and if I understand correctly, I have to make a class, that has a static function suite(), which returns an instance of PHPUnit_Framework_TestSuite, and add tests to this suite, as noted on http://www.phpunit.de/manual/current/en/textui.html.
我想使用cli测试运行器,如果我理解正确,我必须创建一个类,它有一个静态函数suite(),它返回一个PHPUnit_Framework_TestSuite的实例,并向这个套件添加测试,如上所述http://www.phpunit.de/manual/current/en/textui.html。
So far I have come up with:
到目前为止,我想出了:
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 is a very basic test class, that extends PHPUnit_Framework_TestCase. When I run "phpunit MyTestFW", I always get:
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.
Could someone help me out a little please?
有人可以帮我一点吗?
1 个解决方案