groupOrder() 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 group.
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 group. - 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 group.
- The priority order to assign to the group.
Result
- 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
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.