ninny project 单元测试框架使用说明

系统运行要求 PHPUnit 3.1.x PHPUnit 的安装 参考:http://www.phpunit.de/pocket_guide/3.1/en/installation.html 建议使用 Pear 方式安装。 Pear 包的安装请参考http://pear.php.net/manual/en/installation.php 测试用例的编写 参考:http://www.phpunit.de/pocket_guide/3.1/en/writing-tests-for-phpunit.html 应注意,在本框架使用中实际无需在测试用例加载任何文件。 配置文件的设置 <?xml version=’1.0′ encoding=’UTF-8′ ?> <AllTests> <TestSuite> <name>FoobarTest</name> <require>AnotherFoobar.php</require> </TestSuite> <Test> <class>Foo_Bar_AllTest</class> <method>suite</method> <require>/home/foo/bar/AnotherLib.php</require> </Test> </AllTests> TestSuite? 标签指定需要加载的单元测试用例。name 标签指定测试用例名(类名)。 Test 为一组单元测试用例。class 标签指定测试用例组类名,method 标签指定该类返回 PHPUnit_Framework_TestSuite 实例的类方法。 类名的命名应遵从 Zend Framework 的命名规则,即下划线分隔文件路径作为类名。如:类文件存放于 Foo/Bar/AllTest.php,则类对应为 class Foo_Bar_AllTest {…}。 测试用例和测试用例组都将自动加载。保存于 include path 下,符合 Zend Framework 类命名规范的类也都将自动加载(使用 Zend_Loader::registerAutoload() …