Some reminiscences, some memories

Just another boring day
« NetBeans 6.0 正式发布了
备忘,windows下 vim 使用 tab 的方法 »

12

Dec

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

mikespook 

系统运行要求

  • 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() 方法)。若还需加载其他文件,应指定 require 标签,require 标签内容为待加载文件的完整路径或相对于测试目录(tests)的相对路径。

 

执行测试

  1. php 的 cli 程序应在系统 PATH 中。
  2. PHPUnit 的执行程序应在系统 PATH 中(Windows 下为 PHPUnit.bat,Linux 下为 PHPUnit.sh)。

All Tests

进入测试框架所在目录,执行 php AllTests?.php。

One Test

进入测试框架所在目录,执行 php OneTest?.php Test_Name。

改进方向

  • 迭代测试用例,子集测试用例可作为独立的测试执行,亦可通过配置文件加载入上级测试执行。
  • 通过配置文件自动生成测试用例框架,编写测试时只需要填写相应测试断言。

This entry was posted on Wednesday, December 12th, 2007 at 04:18 and is filed under ninny Project. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Trackback URI | Comments RSS

 

July 2010
M T W T F S S
« Jun    
 1234
567891011
12131415161718
19202122232425
262728293031  

Recent Comments

  • Rebill on 我们精通精通
  • 食品楼8 on ucweb 面试记
  • nio on 我们精通精通
  • Some reminiscences, some memories » Blog Archive » [翻译]Akihabara 指南,第四部分:地图的卷动 on [翻译]Akihabara 指南,第二部分:精灵的移动
  • Some reminiscences, some memories » Blog Archive » [翻译]Akihabara 指南,第四部分:地图的卷动 on [翻译]Akihabara 指南,第三部分:基本的地图

Tags

乱码 协程 地震 备案 安装 广州 异步 性能 我爱发明 扯淡 招聘 游戏 漏洞 翻译 豆瓣 39.com Adobe akihabara config countdown Demo Flash game engine golang google html5 issue linux Micromedia MongoDB mysql NetBeans nginx NoSQL oracle PHP phpunit Python trac ubuntu xdebug xml xubuntu yield Zend Framework

Blogroll

  • Blog on 27th Floor
  • DBA notes
  • Tim[后端技术]
  • 唐海燕
  • 抚琴居
  • 某人的栖息地
  • 番茄’s Blog
  • 網站製作學習誌
  • 纸老虎传媒

Old friends

  • cbf107

Only

  • 媚惑桃花

OurPNP

  • Biaoest:标的最高级
  • flexsns-官方博客
  • PNP University
  • PNP街坊
  • smallfish 鱼哥的窝子
  • 冰山日志
  • 墙外的光神V5
  • 夜雨's Blog
  • 小冬kobe
  • 小路的奇异世界
  • 广州萌芽工作室
  • 老甘blog
  • 赖勇浩的编程私伙局

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Powered by WordPress
mikespook.com 粤ICP备09065095号