Thanks to
- https://github.com/pyarmak/cmake-gtest-coverage-example.git
- https://github.com/kaizouman/gtest-cmake-example.git
- https://github.com/dmonopoly/gtest-cmake-example.git
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug .. -Dtest=ON
make
cd build && make test
cd build && make coverage_TEST_NAME //To check the coverage
or
build/test/testfoo/testfoo
-
Add testcode mkdir new testXXX folder under test, maybe you just copy one from testfoo add new line: "add_subdirectory(testXXX)" in test/CMakeLists.txt modify BIN_NAME in testXXX/CMakeLists.txt, and add necessery files/libs
-
googletest in under gtest folder you can update the googletest with your needs
-
Make sure the project file build is before testcode