Fixture setup/cleanup order not honoured if no tests use fixture
In the pathological case where setup and cleanup tests are defined for a fixture, but no other test case requires the fixture, there is nothing to enforce that the cleanup test case must run after the setup test case. The following trivial example demonstrates the problem:
add_test(NAME foocleanup COMMAND echo foocleanup)
add_test(NAME foosetup COMMAND echo foosetup)
set_tests_properties(foocleanup PROPERTIES
FIXTURES_CLEANUP foo
)
set_tests_properties(foosetup PROPERTIES
FIXTURES_SETUP foo
)
The default behaviour of CTest when not run in parallel will be to execute tests in order unless dependencies or fixtures require a different order. Typical output of the above for me looks something like the following:
Test project /home/me/builds/testProj
Start 1: foocleanup
1/2 Test #1: foocleanup ....................... Passed 0.00 sec
Start 2: foosetup
2/2 Test #2: foosetup ......................... Passed 0.00 sec
100% tests passed, 0 tests failed out of 2
Total Test time (real) = 0.02 sec
The setup test should always run before the cleanup test, even in this pathological scenario.