FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

appendTest() method from fcf::NTest::Storage class

void appendTest(const fcf::NTest::Test& a_test)

Class: fcf::NTest::Storage

Package: fcfTest

File: test.hpp

Available from version: 1.2.2

Registers a new test case into the global storage.

The appendTest method is the core mechanism for adding new test cases to the framework. When a test is registered, it is stored in a hierarchical structure organized by parts and groups.

This method is typically called automatically by the FCF_TEST_DEFINE macro, but it can be used manually to programmatically build a test suite.

Arguments

const fcf::NTest::Test& a_test
- The fcf::NTest::Test object containing metadata and the function pointer to execute.

Example: Manual Test Registration

Demonstrating how to register a test case manually without using the standard macros.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> void myManualTest() { FCF_TEST(1 + 1 == 2); } int main(int a_argc, char* a_argv[]) { bool error = false; fcf::NTest::Storage& storage = fcf::NTest::storage(); // 1. Create a Test object manually fcf::NTest::Test manualTest = {"ManualPart", 0, "ManualGroup", 0, "ManualTest", 0, myManualTest}; // 2. Append it to storage storage.appendTest(manualTest); // 3. Run the tests fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

Performing the test: "ManualPart" -> "ManualGroup" -> "ManualTest" ... [SUCCESS] Test completed successfully (0.000`001`083 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`001`083 sec