I have several .cpp files that contain tests for different classes and look like this:
#include <gtest/gtest.h>
namespace {
//lots of tests
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
and a CMakeLists.txt file that looks like this:
add_subdirectory(/usr/src/gtest gtest)
include_directories(${GTEST_INCLUDE_DIR})
add_executable(TestA TestA.cpp)
target_link_libraries(TestA
gtest
)
add_executable(TestB TestB.cpp)
target_link_libraries(TestB
gtest
)
add_executable(TestC TestC.cpp)
target_link_libraries(TestC
gtest
)
I like this setup because it's handy to run just the tests for the component I am currently working on. Executing one Test file is obviously much faster than executing all of them. However, every now and then I want to run all tests. How can I achieve this easily within my setup?