tmt icon indicating copy to clipboard operation
tmt copied to clipboard

Define test fixture relationship between tmt tests

Open LecrisUT opened this issue 3 months ago • 1 comments

CMake uses a similar idea, where you define one test to have a setup/teardown relationship with another test so that:

  • The test run order is guaranteed
  • If a test is selected, the setup and teardown tests are selected as well
  • If a setup fails, the test is not run
  • If the setup is reported as skipped, the behavior in CMake is ill-defined, had a proposal there to also skip all associated tests
  • The setup/teardown tests are run only once even if they are used for multiple tests

I think we should adopt a similar feature, something like

/tests:
  /setup:
    test: ./my_setup.sh
  /main-test-1:
    test: ./test_1.sh
    fixture:
      setup: /tests/setup
      teardown: /tests/teardown
  /teardown:
    test: ./my_teardown.sh

#825 and #1966 are similar but as check. I think it is valuable to have both approaches as, check to run in different context for each test (pytest fixture function scope equivalent), and this one run only once per plan (pytest fixture session scope equivalent)

LecrisUT avatar Nov 14 '25 11:11 LecrisUT

Is this possibly a duplicate of #1897?

psss avatar Nov 19 '25 09:11 psss