Type: int
Class: fcf::NTest::Test
Package: fcfTest
File:
test.hpp
( link_to_the_declaration_in_the_file )
Available from version: 1.2.2
The execution priority of the specific test case.
The testOrder property determines the execution sequence of individual tests within a single group. By default, tests are executed in alphabetical order by their test.
By using the FCF_TEST_TEST_ORDER macro, you can override this behavior and ensure that specific tests run first or last within their group.
Example: Ordering Individual Tests
Demonstrating how to use FCF_TEST_TEST_ORDER to run a specific test before others in the same group.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
FCF_TEST_DEFINE("App", "UI", "ButtonTest") {
const fcf::NTest::Test& test = fcf::NTest::state().test();
fcf::NTest::log() << "Name order: '" << test.testOrder << std::endl;
FCF_TEST(true);
}
FCF_TEST_DEFINE("App", "UI", "MenuTest") {
const fcf::NTest::Test& test = fcf::NTest::state().test();
fcf::NTest::log() << "Name order: '" << test.testOrder << std::endl;
FCF_TEST(true);
}
// Force 'MenuTest' to run before 'ButtonTest'
FCF_TEST_TEST_ORDER("MenuTest", 1);
FCF_TEST_TEST_ORDER("ButtonTest", 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: "App" -> "UI" -> "MenuTest" ...
> Name order: '1
[SUCCESS] Test completed successfully (0.000`006`711 sec)
Performing the test: "App" -> "UI" -> "ButtonTest" ...
> Name order: '2
[SUCCESS] Test completed successfully (0.000`001`883 sec)
[SUCCESS] All tests were completed.
Tests: 2 passed, 0 failed, 0 skipped, 2 total
Duration: 0.000`008`594 sec