GTest
Installation in Ubuntu
sudo apt install libgtest-devUsage in CMake
# gtest
find_package(GTest REQUIRED) # GTestConfig.cmake available
include_directories(${GTEST_INCLUDE_DIRS})
add_executable (main src/main.cpp)
target_link_libraries (main ${GTEST_BOTH_LIBRARIES})
# alternatively
include(GoogleTest) # for CMake version > 3.9Tutorial
ASSERT_*versions generate fatal failures when they fail, and abort the current function.EXPECT_*versions generate nonfatal failures, which don’t abort the current function.Test results will show up when you run the GTest executable after compilation.
GMock
When you write a prototype or test, often it’s not feasible or wise to rely on real objects entirely. A mock object implements the same interface as a real object, but lets you specify at run time how it will be used and what it should do.
GMock has been merged into GTest project in 2019.
Github Repository: https://github.com/google/googlemock
Last updated
Was this helpful?