Type: void
Class: fcf::NTest::Test
Package: fcfTest
File:
test.hpp
( link_to_the_declaration_in_the_file )
Available from version: 1.2.1
Sets the execution priority for a specific part.
The partOrder property is used to define a deterministic execution sequence for different parts in the test suite. By default, parts are executed in alphabetical order by their name.
By assigning an integer value to a part, you can control its position in the execution queue. Lower values are executed earlier.
Example: Controlling Part Execution Order
Demonstrating how to use FCF_TEST_PART_ORDER to ensure critical tests run before general ones.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
// A test in the 'Critical' part
FCF_TEST_DEFINE("Critical", "Core", "StartupTest") {
const fcf::NTest::Test& test = fcf::NTest::state().test();
fcf::NTest::log() << "Part order: '" << test.partOrder << std::endl;
FCF_TEST(true);
}
// A test in the 'General' part
FCF_TEST_DEFINE("General", "Core", "UtilityTest") {
const fcf::NTest::Test& test = fcf::NTest::state().test();
fcf::NTest::log() << "Part order: '" << test.partOrder << std::endl;
FCF_TEST(true);
}
// Register execution order: 'Critical' (1) runs before 'General' (2)
FCF_TEST_PART_ORDER("Critical", 1);
FCF_TEST_PART_ORDER("General", 2);
int main(int a_argc, char* a_argv[]) {
bool error = false;
fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error);
return error ? 1 : 0;
}
Output:
Performing the test: "Critical" -> "Core" -> "StartupTest" ...
> Part order: '1
[SUCCESS] Test completed successfully (0.000`006`302 sec)
Performing the test: "General" -> "Core" -> "UtilityTest" ...
> Part order: '2
[SUCCESS] Test completed successfully (0.000`001`889 sec)
[SUCCESS] All tests were completed.
Tests: 2 passed, 0 failed, 0 skipped, 2 total
Duration: 0.000`008`191 sec