This module defines functions to help use the Google Test infrastructure.
gtest_add_tests
Automatically add tests with CTest by scanning source code for Google Test macros:
gtest_add_tests(TARGET target [SOURCES src1...] [EXTRA_ARGS arg1...] [WORKING_DIRECTORY dir] [TEST_PREFIX prefix] [TEST_SUFFIX suffix] [SKIP_DEPENDENCY] [TEST_LIST outVar] )
TARGET target
SOURCES src1...
SOURCES
property of the specified target
will be used to obtain the list of sources.EXTRA_ARGS arg1...
WORKING_DIRECTORY dir
TEST_PREFIX prefix
prefix
to be prepended to the name of each discovered test case. This can be useful when the same source files are being used in multiple calls to gtest_add_test()
but with different EXTRA_ARGS
.TEST_SUFFIX suffix
TEST_PREFIX
except the suffix
is appended to the name of every discovered test case. Both TEST_PREFIX
and TEST_SUFFIX
can be specified.SKIP_DEPENDENCY
TEST_LIST outVar
outVar
will be populated in the calling scope with the list of discovered test cases. This allows the caller to do things like manipulate test properties of the discovered tests.include(GoogleTest) add_executable(FooTest FooUnitTest.cxx) gtest_add_tests(TARGET FooTest TEST_SUFFIX .noArgs TEST_LIST noArgsTests ) gtest_add_tests(TARGET FooTest EXTRA_ARGS --someArg someValue TEST_SUFFIX .withArgs TEST_LIST withArgsTests ) set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10) set_tests_properties(${withArgsTests} PROPERTIES TIMEOUT 20)
For backward compatibility reasons, the following form is also supported:
gtest_add_tests(exe args files...)
exe
args
""
for no arguments.files...
AUTO
to specify that exe
is the name of a CMake executable target whose sources should be scanned.include(GoogleTest) set(FooTestArgs --foo 1 --bar 2) add_executable(FooTest FooUnitTest.cxx) gtest_add_tests(FooTest "${FooTestArgs}" AUTO)
© 2000–2017 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.9/module/GoogleTest.html