FIXTURES_SETUP.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. FIXTURES_SETUP
  2. --------------
  3. .. versionadded:: 3.7
  4. Specifies a list of fixtures for which the test is to be treated as a setup
  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 setup tests are ordinary tests with all of the usual test
  8. functionality. Setting the ``FIXTURES_SETUP`` property for a test has two
  9. primary effects:
  10. - CTest will ensure the test executes before any other test which lists the
  11. fixture name(s) 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 setup 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_SETUP``.
  16. A setup test can have multiple fixtures listed in its ``FIXTURES_SETUP``
  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 setup test defined. If there are
  19. multiple setup tests for a fixture, projects can control their order with the
  20. usual :prop_test:`DEPENDS` test property if necessary.
  21. A setup test is allowed to require other fixtures, but not any fixture listed
  22. in its ``FIXTURES_SETUP`` property. For example:
  23. .. code-block:: cmake
  24. # Ok: dependent fixture is different to setup
  25. set_tests_properties(setupFoo PROPERTIES
  26. FIXTURES_SETUP Foo
  27. FIXTURES_REQUIRED Bar
  28. )
  29. # Error: cannot require same fixture as setup
  30. set_tests_properties(setupFoo PROPERTIES
  31. FIXTURES_SETUP Foo
  32. FIXTURES_REQUIRED Foo
  33. )
  34. If any of a fixture's setup tests fail, none of the tests listing that fixture
  35. in its :prop_test:`FIXTURES_REQUIRED` property will be run. Cleanup tests will,
  36. however, still be executed.
  37. See :prop_test:`FIXTURES_REQUIRED` for a more complete discussion of how to use
  38. test fixtures.