Reputation: 371
I would like to make groups of CTests to improve readability with a structure like this:
How can I do this? My current CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
project(Test)
set(CMAKE_CXX_STANDARD 14)
enable_testing()
add_executable(env environment.cpp)
add_test(Environment env)
add_subdirectory(unit) # Includes tests 'UserInterface' and 'Test2'
The tests in the subdirectory are not grouped together when I run it:
Upvotes: 4
Views: 1013
Reputation: 38295
CTest
doesn't support this, as it's not a classical unit testing framework, but rather a convenient way to "run stuff" that is already configured (in most cases) to be built with CMake
.
What you can do is:
add_test(foo_...)
, you can run this group with ctest -R foo_
for example.FIXTURES_CLEANUP
). However, this doesn't give you structure per se, it only ensures a certain existing test is run as a setup/teardown before/after the test in question.Upvotes: 4