Class: fcf::NTest::Storage
Package: fcfTest
File:
test.hpp
(
link_to_the_declaration_in_the_file
,
link_to_the_implementation_in_the_file
)
Available from version: 1.2.1
Sets or gets the execution priority of a specific test group.
The groupOrder method allows you to control the execution order of groups within a part. This is useful for organizing sub-categories of tests.
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 group.
- 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 group.
int a_order
- The priority order to assign to the group.
Result
int
- The assigned priority order for the group.
Example: Ordering Groups within a Part
Demonstrating how to ensure specific groups run before others within the same part.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
FCF_TEST_DEFINE("Lib", "API", "Test1") {
FCF_TEST(true);
}
FCF_TEST_DEFINE("Lib", "Utils", "Test2") {
FCF_TEST(true);
}
int main(int a_argc, char* a_argv[]) {
bool error = false;
fcf::NTest::Storage& storage = fcf::NTest::storage();
// 1. Set group order: 'API' group runs before 'Utils' group
storage.groupOrder("API", 1);
storage.groupOrder("Utils", 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: "Lib" -> "API" -> "Test1" ...
[SUCCESS] Test completed successfully (0.000`000`562 sec)
Performing the test: "Lib" -> "Utils" -> "Test2" ...
[SUCCESS] Test completed successfully (0.000`000`273 sec)
[SUCCESS] All tests were completed.
Tests: 2 passed, 0 failed, 0 skipped, 2 total
Duration: 0.000`000`835 sec