testOrder() method from fcf::NTest::Storage class
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.1
Sets or gets the execution priority of a specific test case.
The
This method has two distinct behaviors depending on whether it is used for reading or writing:
- Write Mode: When called with an
int argument, it assigns a priority value to the specified test name. - Read Mode: When called with a single
const char* argument, it returns the assigned priority, or the default constantFCF_TEST_ORDER_DEFAULT if not set.
Arguments
- The name of the test case.
- The priority order to assign to the test.
Result
- The assigned priority order for the test.
Example: Ordering Individual Tests
Demonstrating how to force a specific test to run first within its group.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
FCF_TEST_DEFINE ("Math", "Ops", "Add") {
FCF_TEST (true);
}
FCF_TEST_DEFINE ("Math", "Ops", "Sub") {
FCF_TEST (true);
}
int main(int a_argc, char* a_argv[]) {
bool error = false;
fcf::NTest::Storage & storage = fcf::NTest::storage ();
// 1. Set test order: 'Sub' runs before 'Add'
storage.testOrder ("Sub", 1);
storage.testOrder ("Add", 2);
// 2. Run the tests
fcf::NTest::cmdRun (a_argc, a_argv, fcf::NTest::CRM_RUN , &error);
return error ? 1 : 0;
}
Output:
Performing the test: "Math" -> "Ops" -> "Sub" ...
[SUCCESS] Test completed successfully (0.000`001`000 sec)
Performing the test: "Math" -> "Ops" -> "Add" ...
[SUCCESS] Test completed successfully (0.000`001`000 sec)
[SUCCESS] All tests were completed.
Tests: 2 passed, 0 failed, 0 skipped, 2 total
Duration: 0.000`002`000 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.