CppUnit测试环境搭建流程及示例 Windows环境

上一篇 / 下一篇  2012-06-26 10:28:21 / 个人分类:测试工具-单元测试

------------------------- 来源:软件测试经验分享博客 MyTestLife.com--------------------

软件:CppUnit-1.12.1

下载地址:http://download.csdn.net/source/609421

使用环境:Visual C++ 6. 0, WindowsXP

操作流程:

<!--[if !supportLists]-->1、<!--[endif]-->解压CppUnit-1.12.1安装包

主要的文件夹有:

<!--[if !supportLists]-->l<!--[endif]-->doc: CppUnit的说明文档。另外,代码的根目录,还有三个说明文档,分别是INSTALLINSTALL-unixINSTALL-WIN32.txt

<!--[if !supportLists]-->l<!--[endif]-->examples: CpppUnit提供的例子,也是对CppUnit自身的测试,通过它可以学习如何使用CppUnit测试框架进行开发。

<!--[if !supportLists]-->l<!--[endif]-->include: CppUnit头文件。

<!--[if !supportLists]-->l<!--[endif]-->src: CppUnit源代码目录。

<!--[if !supportLists]-->2、<!--[endif]-->进入src文件夹,用VC++6.0打开其中的工程文件CppUnitLibraries.dsw后编译,在选项中点击Tools->Options->Directories,Show directories for:选项框中选择Include files,将%CppUnit安装目录%\INCLUDE添加到列表中,再将%CppUnit安装目录%\LIB加入到Library files列表中,如图1、图2

cppunit<!--[endif]-->

1

cppunit<!--[endif]-->

2

<!--[if !supportLists]-->3、<!--[endif]-->进入example文件夹,用VC打开examples.dsw。将CppUnitTestApp工程设为Active ProjectWin32 Debug),编译后,根据Build提示信息进行设置,选择Project->Settings->Executable for debug session选项中点击Browse,选择CppUnitApp.exe打开,然后OK,如图3

cppunit

3

<!--[if !supportLists]-->4、<!--[endif]-->点击Run后全部通过,如图4

cppunit

4

<!--[if !supportLists]-->5、<!--[endif]-->点击Browse,还可以选择要进行的单元测试,如图5

cppunit

5

<!--[if !supportLists]-->6、<!--[endif]-->执行结果如图6

cppunit

6

<!--[if !supportLists]-->7、<!--[endif]-->我们可以选择文本形式的测试环境,选择Project->Settings->Executable for debug session选项中点击Browse,如图7

cppunit

7

<!--[if !supportLists]-->8、<!--[endif]-->点击“打开”->Ok后,点击Run,结果如图8

cppunit

8

<!--[if !supportLists]-->9、<!--[endif]-->下图9为演示失败的测试,文本形式显示了失败的语句所在的文件及所在的行数:

9

在基于GUI的测试环境中,进度条显示绿色表示测试成功,显示红色则表示失败,如图10

cppunit

10


TAG:

 

评分:0

我来说两句

Open Toolbar