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

|
|
相关文章:相关软件: |
|