Running gtests on your C++ programs using g++ on Ubuntu: Installation Install CMake: sudo apt install cmake Switch to home directory and: git clone --depth 1 https://github.com/google/googletest.git Build it: cd ~/googletest mkdir build cd build cmake -Dgtest_build_samples=ON -Dgtest_build_tests=ON ~/googletest make make test ./googlemock/gtest/sample1_unittest Install the googletest and googlemock .a and .h files: sudo cp -r -v ~/googletest/googletest/include/gtest /usr/local/include sudo cp -r -v ~/googletest/googlemock/include/gmock /usr/local/include sudo cp -v ~/googletest/build/googlemock/lib*.a /usr/local/lib sudo cp -v ~/googletest/build/googlemock/gtest/lib*.a /usr/local/lib TEST() and code in same file - Test Fail To compile and run: g++ 01sqrt_fail.cpp -lgtest -lpthread -o 01sqrt_fail ./01sqrt_fail Output: TEST() and code in same file - Test Pass To compile and run: g++ 01sqrt_pass.cpp -lgtest -lpthread -o