the Compartmented Robust Posix C++ Unit Test system


A test and testsuite modifier to state dependencies. The test(s) will not run until all dependencies are resolved, i.e. the referred tests have succeeded.

Used in: The modifier list of a test definition or testsuite definition. See TEST(name, ...) and TESTSUITE(name, ...)

The parameter to DEPENDS_ON(...) is a comma separated list of dependencies. Each dependency can be either a the name of a test, or ALL_TESTS(testsuitename)

When DEPENDS_ON(...) is used for a testsuite, the dependencies applies for all tests in the testsuite. It is possible to constrain a single test further than the testsuite it resides in, by adding a DEPENDS_ON(...) modifier to the test.

It is often a good idea to let testsuites depend on testsuites, and tests to depend on other tests inside the same testsuite.
A dependency on a DISABLED_TEST(name, ...) is handled as if the disabled test has succeeded.
DEPENDS_ON(...) can only be included once in the modifier list for each TEST(name, ...) or TESTSUITE(name, ...).
If you use GCC version 4.3 or higher, and compile your test sources with -std=c++0x, there is no limit to the number of parameters, otherwise you can list maximum 17 names in the parameter list.

Example: The test program

     #include <crpcut.hpp>
     struct A
       A() {}
       ~A() { exit(0); }
       void do_something() const {}
         (void)new A(); // intentionally leak
       TEST(destroy, DEPENDS_ON(construct))
         A *p = new A();
         delete p;
         A obj;
     int main(int argc, char *argv[])
       return crpcut::run(argc, argv);

reports one failed test, and one that did not run:

     FAILED!: basics::destroy
     phase="running"  --------------------------------------------------------------
     Exited with code 0
     Expected normal exit
     The following tests were blocked from running:
     3 test cases selected
                    Sum   Critical   Non-critical
     PASSED   :       1          1              0
     FAILED   :       1          1              0
     UNTESTED :       1

See also the -n / --nodeps command line flag.