# specify dependencies between add\_test tests?

**URL:** https://discourse.cmake.org/t/specify-dependencies-between-add-test-tests/4319
**Category:** Usage
**Created:** [October 22, 2021, 2:37pm UTC](https://discourse.cmake.org/t/specify-dependencies-between-add-test-tests/4319 "2021-10-22T14:37:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![wolfman21](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@wolfman21](https://discourse.cmake.org/u/wolfman21)
#### Post date: [October 22, 2021, 2:37pm UTC](https://discourse.cmake.org/t/specify-dependencies-between-add-test-tests/4319/1 "2021-10-22T14:37:24Z")

</div>

Is there a way to explicitly specify the order of execution for `ctest` tests added with `add_test`? Specifically, I have one test that generates output which is required as input by two subsequent tests.

It looks like there may be a way to use [`add_custom_target(...)`](https://cmake.org/cmake/help/latest/command/add_custom_target.html?highlight=add_custom_target) but I haven’t flushed that out yet. AFAIK, `add_test` does not create targets so maybe one `add_custom_target` call for each test with the `DEPENDS` option … that seems a bit like a kludge.

Thank you.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [October 22, 2021, 9:32pm UTC](https://discourse.cmake.org/t/specify-dependencies-between-add-test-tests/4319/2 "2021-10-22T21:32:50Z")

</div>

You need test properties to enforce the kind of behavior you’re after. Take a look at the [FIXTURES\_SETUP](https://cmake.org/cmake/help/latest/prop_test/FIXTURES_SETUP.html) and [FIXTURES\_REQUIRED](https://cmake.org/cmake/help/latest/prop_test/FIXTURES_REQUIRED.html) test properties (start with the docs for the latter). They allow you to specify that one or more tests need some other test(s) to run first. For completeness, there’s also [FIXTURES\_CLEANUP](https://cmake.org/cmake/help/latest/prop_test/FIXTURES_CLEANUP.html).

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [October 23, 2021, 9:14pm UTC](https://discourse.cmake.org/t/specify-dependencies-between-add-test-tests/4319/3 "2021-10-23T21:14:52Z")

</div>

I forgot I also wrote a more detailed article describing the feature here: [https://crascit.com/2016/10/18/test-fixtures-with-cmake-ctest/](https://crascit.com/2016/10/18/test-fixtures-with-cmake-ctest/)

---

<div class="post-metadata">

### Author: ![wolfman21](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@wolfman21](https://discourse.cmake.org/u/wolfman21)
#### Post date: [October 25, 2021, 1:54pm UTC](https://discourse.cmake.org/t/specify-dependencies-between-add-test-tests/4319/4 "2021-10-25T13:54:00Z")

</div>

Thank you. That worked perfectly. 👍
