UsingSuites
DocumentationA Test Suite is a composite used to group similar tests together, allowing you to test them as a group (instead of individually). simplectest has limited support for the concept of testing suites.
To write a test suite, first put the test suite into its own file (e.g. "test-suite.cpp"):
#include "test-suite.h"
START_SUITE(mysuite)
START_TEST("myTest")
... normal testing code ...
END_TEST()
... more tests ...
END_SUITE()
Make a header file for the test suite (e.g. "test-suite.h"):
#ifndef _TESTS_SUITE_H
#define _TESTS_SUITE_H
// include test definitions
#include "tests.h"
// create suite declaration
DEFINE_SUITE(mysuite)
#endif
Finally, in the actual test file (e.g. "tests.cpp"), add the suite header declaration and the call to run the suite:
#include "tests.h"
#include "test-suite.h"
START_TESTS()
// run mysuite
SUITE(mysuite);
END_TESTS()
That's all you need to do. You can then compile all the source code, link the classes together, and voila - a test suite. To disable the test suite, you can simply comment out the SUITE() line in the main test file.
You can run the suite individually by defining TEST_INDIVIDUAL when compiling the suite, i.e:
$ g++ test-suite.cpp -o test-suite.o -DTEST_INDIVIDUAL
$ g++ test-suite.o -o test-suite
$ ./test-suite
See MacroReference for more information.