Type:
class fcf::NTest::TestPath
Package: fcfTest
File: test.hpp
Available from version: 1.2.4
A simple structure representing the hierarchical location of a test case within the framework (Part, Group, and Test name).
The fcf::NTest::TestPath structure is a lightweight container used to uniquely identify a test case within the framework's hierarchical organization. It encapsulates the three levels of grouping: the part, the group, and the test name. This structure is primarily used as a key for looking up parameters or identifying specific test contexts during execution.
Properties
- The name of the top-level logical grouping (Part) in the test hierarchy.
- The name of the intermediate logical grouping (Group) within a Part.
- The name of the specific test case within a group.
Example: Manual TestPath Construction
Demonstrates how to manually create a TestPath object to represent a specific location in the test hierarchy.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
FCF_TEST_BEFORE_DEFINE("*", "*", "*", fcf::NTest::FL_GLOBAL) {
// Initialize the path object to the desired test
fcf::NTest::TestPath path = {"Core", "Math", "AdditionTest"};
// Add multiple test parameters
fcf::NTest::storage().appendParamValue(path, (std::string)"one");
fcf::NTest::storage().appendParamValue(path, (std::string)"two");
fcf::NTest::storage().appendParamValue(path, (std::string)"three");
}
FCF_TEST_DEFINE("Core", "Math", "AdditionTest") {
// Get the value of the test parameter
std::string paramValue = *fcf::NTest::state().param().cast<std::string>();
fcf::NTest::log() << "Param value: " << paramValue << std::endl;
FCF_TEST(true);
}
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: "Core" -> "Math" -> "AdditionTest" ...
== Parameter set: 1
> Param value: one
== Parameter set: 2
> Param value: two
== Parameter set: 3
> Param value: three
[SUCCESS] Test completed successfully (0.000`024`501 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`024`501 sec