1. 杂问
仿gtest为VC6写的单元测试框架
http://blog.youkuaiyun.com/riag/category/115856.aspx
一篇关于gmock的导读文章:http://blog.youkuaiyun.com/learnhard/archive/2010/07/23/5757461.aspx
2. 下载
* svn checkout
svn checkout http://googlemock.googlecode.com/svn/trunk/ gmock-svn
* download
# wget http://googlemock.googlecode.com/files/gmock-1.6.0.zip
# unzip gmock-1.6.0.zip
3. 安装执行
* 生成gmock库文件
#./configure
#make
主要生成物:
[root@localhost lib]# ll
总计 16
-rw-r--r-- 1 root root 958 06-05 06:31 libgmock.la
-rw-r--r-- 1 root root 1288 06-05 06:31 libgmock_main.la
Q:*.la如何使用?
* 生成样例程序并执行
[root@localhost gmock-1.6.0]# cd make
[root@localhost make]# ll
总计 8
-r--r--r-- 1 root root 3501 04-16 03:51 Makefile
[root@localhost make]# make
...
g++ -I../gtest/include -I../include -g -Wall -Wextra -lpthread gmock_test.o gmock_main.a -o gmock_test
[root@localhost make]# ./gmock_test
Running main() from gmock_main.cc
[==========] Running 13 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 6 tests from InitGoogleMockTest
[ RUN ] InitGoogleMockTest.ParsesInvalidCommandLine
[ OK ] InitGoogleMockTest.ParsesInvalidCommandLine (0 ms)
[ RUN ] InitGoogleMockTest.ParsesEmptyCommandLine
[ OK ] InitGoogleMockTest.ParsesEmptyCommandLine (0 ms)
[ RUN ] InitGoogleMockTest.ParsesSingleFlag
[ OK ] InitGoogleMockTest.ParsesSingleFlag (1 ms)
[ RUN ] InitGoogleMockTest.ParsesUnrecognizedFlag
[ OK ] InitGoogleMockTest.ParsesUnrecognizedFlag (0 ms)
[ RUN ] InitGoogleMockTest.ParsesGoogleMockFlagAndUnrecognizedFlag
[ OK ] InitGoogleMockTest.ParsesGoogleMockFlagAndUnrecognizedFlag (0 ms)
[ RUN ] InitGoogleMockTest.CallsInitGoogleTest
[ OK ] InitGoogleMockTest.CallsInitGoogleTest (0 ms)
[----------] 6 tests from InitGoogleMockTest (25 ms total)
[----------] 6 tests from WideInitGoogleMockTest
[ RUN ] WideInitGoogleMockTest.ParsesInvalidCommandLine
[ OK ] WideInitGoogleMockTest.ParsesInvalidCommandLine (0 ms)
[ RUN ] WideInitGoogleMockTest.ParsesEmptyCommandLine
[ OK ] WideInitGoogleMockTest.ParsesEmptyCommandLine (0 ms)
[ RUN ] WideInitGoogleMockTest.ParsesSingleFlag
[ OK ] WideInitGoogleMockTest.ParsesSingleFlag (0 ms)
[ RUN ] WideInitGoogleMockTest.ParsesUnrecognizedFlag
[ OK ] WideInitGoogleMockTest.ParsesUnrecognizedFlag (1 ms)
[ RUN ] WideInitGoogleMockTest.ParsesGoogleMockFlagAndUnrecognizedFlag
[ OK ] WideInitGoogleMockTest.ParsesGoogleMockFlagAndUnrecognizedFlag (1 ms)
[ RUN ] WideInitGoogleMockTest.CallsInitGoogleTest
[ OK ] WideInitGoogleMockTest.CallsInitGoogleTest (0 ms)
[----------] 6 tests from WideInitGoogleMockTest (34 ms total)
[----------] 1 test from FlagTest
[ RUN ] FlagTest.IsAccessibleInCode
[ OK ] FlagTest.IsAccessibleInCode (0 ms)
[----------] 1 test from FlagTest (3 ms total)
[----------] Global test environment tear-down
[==========] 13 tests from 3 test cases ran. (81 ms total)
[ PASSED ] 13 tests.

本文介绍如何为Visual C++ 6.0安装一个类似Google Test的单元测试框架,并提供gMock的安装步骤及样例程序的执行情况。包括从源码仓库下载、编译配置到最终运行测试用例的全过程。
1795

被折叠的 条评论
为什么被折叠?



