1.源码地址:
https://github.com/google/googletest.git
文档:http://www.cnblogs.com/coderzh/archive/2009/04/06/1430364.html
参考:http://blog.csdn.net/breaksoftware/article/details/50917733
使用GitHub Desktop克隆下载

介绍:
make目录: makefile文件
samples目录:google提供的样例1~10层层深入
include目录:测试所需头文件
2.生成静态库gtest_main.a
参考:http://www.cnblogs.com/bangerlee/archive/2011/10/02/2197879.html
参考:http://www.cnblogs.com/hcu5555/archive/2015/04/30/4468847.html
在make目录下运行make,生成多个文件(其实包含静态库gtest_main.a),其中sample1_unittest就是sample1的可执行文件了。运行./sample1_unittest可看到用例执行结果

执行./sample1_unittest

3.把gtest-main.a拷贝赋值到samples目录中

4.编译
g++ -I ../include/ -c sample2_unittest.cc
g++ -I ../include/ -c sample2.cc
生成sample2.0和sample2_unittest.o文件

5.链接
g++ -I ../include/ sample2.o sample2_unittest.o gtest_main.a -lpthread -o test2
生成可执行文件test2

6.执行test2
./test2

网友评论