环境:ubuntu 14.04
编译器:g++
-
Get the googletest framework
$ wget https://github.com/google/googletest/archive/release-1.7.0.zip
-
Unzip and build google test
$ unzip gtest-1.7.0.zip $ cd gtest-1.7.0 $ ./configure $ make
-
"Install" the headers and libs on my system.
$ sudo cp -a include/gtest /usr/include $ sudo cp -a lib/.libs/* /usr/lib/
-
Update the cache of the linker
sudo ldconfig -v | grep gtest
test.cpp
文件:
#include <gtest/gtest.h>
TEST(MathTest, TwoPlusTwoEqualsFour) {
EXPECT_EQ(2 + 2, 4);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest( &argc, argv );
return RUN_ALL_TESTS();
}
$ g++ -Wall -o test test.cpp -lgtest -lgtest_main -lpthread