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

fcf::NTest::Storage class

Type:
class fcf::NTest::Storage

Package: fcfTest

File: test.hpp

Available from version: 1.2.1

A thread-safe central repository for all registered tests, fixtures, and execution metadata.

The fcf::NTest::Storage class acts as the backbone of the fcfTest framework. It serves as a thread-safe container that organizes and stores all registered fcf::NTest::Test objects, fcf::NTest::Fixture objects, and execution orderings (for parts, groups, and tests). The class ensures data integrity in multithreaded environments using internal mutex locking.

Methods
int partOrder(const char* a_name) const
void partOrder(const char* a_name, int a_order)
- Sets or gets the execution priority of a specific test part.
int groupOrder(const char* a_name) const
void groupOrder(const char* a_name, int a_order)
- Sets or gets the execution priority of a specific test group.
int testOrder(const char* a_name) const
void testOrder(const char* a_name, int a_order)
- Sets or gets the execution priority of a specific test case.
std::set<fcf::NTest::Test> selectTests(const Options& a_options) const
- Filters and selects a subset of registered tests based on provided selectors and ignore rules.
void appendTest(const fcf::NTest::Test& a_test)
- Registers a new test case into the global storage.
std::vector<fcf::NTest::Fixture> fixtures() const
- Returns a collection of all registered test fixtures.
void appendFixture(const fcf::NTest::Fixture& a_fixture)
- Registers a new test fixture into the global storage.
std::vector<fcf::NTest::SharedPtrAny> params(const std::string& a_part, const std::string& a_group, const std::string& a_test) const
void params(const std::string& a_part, const std::string& a_group, const std::string& a_test, const std::vector<fcf::NTest::SharedPtrAny>& a_params)
- Returns or sets all parameters associated with a specific test.
void appendParam(const std::string& a_partName, const std::string& a_groupName, const std::string& a_testName, fcf::NTest::SharedPtrAny... a_parameterPack)
void appendParam(const fcf::NTest::Test& a_a_test, fcf::NTest::SharedPtrAny... a_parameterPack)
void appendParam(const fcf::NTest::TestPath& a_testPath, fcf::NTest::SharedPtrAny... a_parameterPack)
- Adds a parameters to a specific test case.
template <typename ...TValuePack>
void appendParamValue(const std::string& a_partName, const std::string& a_groupName, const std::string& a_testName, const TValuePack& ...a_parameterPack)
template <typename ...TValuePack>
void appendParamValue(const fcf::NTest::Test& a_a_test, const TValuePack& ...a_parameterPack)
template <typename ...TValuePack>
void appendParamValue(const fcf::NTest::TestPath& a_testPath, const TValuePack& ...a_parameterPack)
- Adds a values as a parameters to a specific test case by automatically wrapping it in fcf::NTest::SharedPtrAny.

Example: Manual Storage Management

Demonstrates how to manually interact with the Storage instance to register tests, set execution orders.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> void myManualTest(){ // Access the global storage instance fcf::NTest::Storage& storage = fcf::NTest::storage(); // Get the group serial number int partOrder = storage.partOrder("Manual"); FCF_TEST(partOrder == 1, partOrder); } int main(int a_argc, char* a_argv[]) { // 1. Access the global storage instance fcf::NTest::Storage& storage = fcf::NTest::storage(); // 2. Register a custom execution order for this part storage.partOrder("Manual", 1); // 3.Register a manual test fcf::NTest::Test test; test.part = "Manual"; test.group = "Storage"; test.test = "Test"; test.testFunction = myManualTest; storage.appendTest(test); // 4. Starting test processing bool error = false; fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

Performing the test: "Manual" -> "Storage" -> "Test" ... [SUCCESS] Test completed successfully (0.000`000`768 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`000`768 sec