FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

testOrder() method from fcf::NTest::Storage class

int testOrder(const char* a_name) const
void testOrder(const char* a_name, int a_order)

Class: fcf::NTest::Storage

Package: fcfTest

File: test.hpp

Available from version: 1.2.1

Sets or gets the execution priority of a specific test case.

The testOrder method provides the finest level of control over test execution, allowing you to specify the exact order of individual test cases within a group.

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 constant FCF_TEST_ORDER_DEFAULT if not set.

Arguments

const char* a_name
- The name of the test case.

int a_order
- The priority order to assign to the test.
Result
int
- 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