https://medium.com/@jgrant.esteve/google-test-compiled-from-source-c7ab87329321
1. get google test source
git clone https://github.com/google/googletest.git
2. cd into googletest.
cmake ..
library files should be generated
make install
this command install header files and library to common path
so you can include gtest header and start writing test cases for your code
3. example files
#include "gtest/gtest.h"
#include "main.cpp"
TEST(Name, Test) {
ASSERT_TRUE(1 == 1);
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
4. compile with command
$ g++ example.cpp -o example -lgtest -lpthread
댓글 없음:
댓글 쓰기