FIXTURES_SETUP.rst 1.7 KB

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