googleMock 依赖于GoogleTest 。GoogleTest安装不多详解
我们在https://github.com/google/googletest 下载google Mock 之后 我们解压文件夹之后进入文件
cd googlemock
cd make
vim Makefile
将gmock.a 改成libgmock.a
gmock_main.a改成 libgmock_main.a
make libgmock.a
make libgmock_main.a
cp ./*.a /lib/
vim test.cpp
输入测试代码
#include "gmock/gmock.h" int main(int argc,char** argv){ testing::InitGoogleMock(&argc,argv); return RUN_ALL_TESTS(); }
运行
g++ test.cpp -I $path/googletest-master/googlemock/include -I $path/googletest-master/googletest/include/ -lgtest -lgmock
$path 为你解压路径
|