DUnit:用于Borland Delphi编程的极终极测试框架Delphi 2005中集成了一个新的功能模块:单元测试(Unit testing)。这里介绍的DUnit是为Delphi4-7而开发的一个单元测试工具。若能随时更新测试程序并且经常反复地执行它们,你就能够更轻易地产生可靠的程序代码,而且在进行修改与重构(refactorings)时更有把握不会破坏原有的程序代码,于是,应用程序等于有了自我测试的能力。
Delphi单元测试工具Dunit介绍
Dunit基本介绍
Dunit是Xunit家族中的一员,用于Dephi的单元测试。是Extreme Programming测试实现Xtreme Testing的一种工具。Dunit是一个Free的测试工具,没有代码覆盖率功能。
Dunit的官方Web Site 是https://sourceforge.net/projects/dunit/。
使用Dunit应该先看看Dunit安装目录下的docREADME.html。本文也是参看Readme写的。
配置测试环境
在使用Dunit前应该将下载的Dunit解压。然后后将Dunit的路径加到菜单 Tools->Environment Options 里面的Library->Library Path中。
Dunit的主要文件
File Description
TestFramework.pas The framework itself.
TestExtensions.pas Decorator classes that may be used to extend test cases.
GUITesting.pas Classes for testing user interfaces (Forms and Dialogs).
TextTestRunner.pas Routines to run tests in console mode.
GUITestRunner.pas The graphical user interface to the framework..
GUITestRunner.dfm The GUITestRunner Form
Dunit基本实现方法(GUI方式)
Dunit的基本实现思路是将被测试代码(单元)与测试代码(单元)分开。提供一个FrameWork及一个运行界面。 所有的测试单元都应继承TtestCase。