其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
cppunit 使用安装 (二)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

基于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()等测试宏
  • 编译测试,或继续到添加测试类或方法。.



相关文章

相关软件