FIXTURES_CLEANUP.rst 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. FIXTURES_CLEANUP
  2. ----------------
  3. .. versionadded:: 3.7
  4. Specifies a list of fixtures for which the test is to be treated as a cleanup
  5. test. These fixture names are distinct from test case names and are not
  6. required to have any similarity to the names of tests associated with them.
  7. Fixture cleanup tests are ordinary tests with all of the usual test
  8. functionality. Setting the ``FIXTURES_CLEANUP`` property for a test has two
  9. primary effects:
  10. - CTest will ensure the test executes after all other tests which list any of
  11. the fixtures in its :prop_test:`FIXTURES_REQUIRED` property.
  12. - If CTest is asked to run only a subset of tests (e.g. using regular
  13. expressions or the ``--rerun-failed`` option) and the cleanup test is not in
  14. the set of tests to run, it will automatically be added if any tests in the
  15. set require any fixture listed in ``FIXTURES_CLEANUP``.
  16. A cleanup test can have multiple fixtures listed in its ``FIXTURES_CLEANUP``
  17. property. It will execute only once for the whole CTest run, not once for each
  18. fixture. A fixture can also have more than one cleanup test defined. If there
  19. are multiple cleanup tests for a fixture, projects can control their order with
  20. the usual :prop_test:`DEPENDS` test property if necessary.
  21. A cleanup test is allowed to require other fixtures, but not any fixture listed
  22. in its ``FIXTURES_CLEANUP`` property. For example:
  23. .. code-block:: cmake
  24. # Ok: Dependent fixture is different to cleanup
  25. set_tests_properties(cleanupFoo PROPERTIES
  26. FIXTURES_CLEANUP Foo
  27. FIXTURES_REQUIRED Bar
  28. )
  29. # Error: cannot require same fixture as cleanup
  30. set_tests_properties(cleanupFoo PROPERTIES
  31. FIXTURES_CLEANUP Foo
  32. FIXTURES_REQUIRED Foo
  33. )
  34. Cleanup tests will execute even if setup or regular tests for that fixture fail
  35. or are skipped.
  36. See :prop_test:`FIXTURES_REQUIRED` for a more complete discussion of how to use
  37. test fixtures.