cppunit 使用安装 (二)

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

基于GUI的测试

新建一个基于dialog的项目

插入你要测试的类或方法的源文件。

修改App类中的Instance方法

添加下列头文件

#include <cppunit/ui/mfc/TestRunner.h>

#include <cppunit/extensions/TestFactoryRegistry.h>

#include "xxxSuite.h"

替换

CCPlusTestDlg dlg;

m_pMainWnd = &dlg;

int nResponse = dlg.DoModal();

if (nResponse == IDOK)

{

// TODO: Place code here to handle when the dialog is

// dismissed with OK

}

else if (nResponse == IDCANCEL)

{

// TODO: Place code here to handle when the dialog is

// dismissed with Cancel

}

CppUnit::MfcUi::TestRunner runner;

runner.addTest(xxxSuite::suite()); //添加测试

runner.run(); //show UI

然后修改Project Settings

Project /setting/ (C/C++) / C++ Language / RTTI 选中

添加testrunner.lib cppunit.lib

确认项目时使用/MD or /MDd边

使用宏 AddingUnitTestMethod.dsm / addSuilt method 增加 test Suite

使用宏 AddingUnitTestMethod.dsm / addClass method 增加 test class.

查找xxxSuite修改成为对应的Suite名称

在你的test class中增加测试方法,原型必须是 void* ()

在class view中点击该方法,到达该方法cpp中的声明的第一行,然后使用 AddingUnitTestMethod.dsm / addTestMethod 添加测试方法声明。

编写测试代码,添加 CPPUNIT_ASSERT_EQUAL()等测试宏

编译测试,或继续到添加测试类或方法。.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航