现在的位置: 首页 > 综合 > 正文

使用CxxTest测试框架

2013年11月18日 ⁄ 综合 ⁄ 共 1066字 ⁄ 字号 评论关闭

vs2003中使用CxxTest测试框架

 

1. 下载CxxTest测试框架,并解压。

   http://jaist.dl.sourceforge.net/sourceforge/cxxtest/cxxtest-3.10.1.zip

 

2. 假设测试项目project1。在project1目录新建新建空白项目testpriject1。

3. 打开项目属性,修改属性“生成事件|预生成事件”,添加命令:

   {path to cxxtest}/cxxtestgen.pl --error-printer -o runner.cpp *.h

4. 修改属性“c/c++|附加包含目录”,添加{path to cxxtest}。

5. 在当前项目目录新建空白的cpp文件 runner.cpp并添加到项目中。

6. 编译执行。

 

vc命令行:

新建runtest.bat:

 

   ../cxxtestgen.pl --error-printer -o runner.cpp TraitsTest.h
   cl /GX /I.. -o runner.exe runner.cpp
   ./runner.exe

 

vc GUI:

新建runtest.bat:

 

  ../cxxtestgen.pl -o runner.cpp --gui=Win32Gui TraitsTest.h
  cl /GX /I.. runner.cpp /link kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib   shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /OUT:runner.exe
    ./runner.exe -keep

 

gcc 命令行:(使用mingw)

新建runtest.bat:

 

   set path=E:/MingW/bin;%path%
   ../cxxtestgen.pl --error-printer -o runner.cpp ../TraitsTest.h
   g++ -o runner.exe -I .. runner.cpp
   ./runner.exe

 

抱歉!评论已关闭.