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

parts from class fcf::NTest::Options::Selector

Property: parts = []

Type: std::vector<std::string>

Class: fcf::NTest::Options::Selector

Package: fcfTest

File: test.hpp

Available from version: 1.1.12

A list of part names to include in the test selection.

The parts property is a collection of strings used to filter the execution of tests based on their top-level hierarchical grouping (the 'Part' level).

When configuring a fcf::NTest::Options::Selector, the following rules apply to the contents of this vector:

  • If the vector is empty, all parts are considered selected.
  • If it contains specific names, only tests belonging to those parts will be executed.
  • The special string "*" or an empty string "" within the vector acts as a wildcard, selecting all elements at this level.
  • Multiple names in the vector are treated using the OR logic (e.g., if you provide {"PartA", "PartB"}, tests from either PartA or PartB will run).

Example: Filtering tests by specific parts

Demonstrating how to use the 'parts' vector to select only tests belonging to specific logical parts of the project.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <vector> #include <string> // --- Test Suite Setup --- // Test in 'Math' part FCF_TEST_DEFINE("Math", "Arithmetic", "Addition") { FCF_TEST(1 + 1 == 2); } // Test in 'Math' part FCF_TEST_DEFINE("Math", "Arithmetic", "Subtraction") { FCF_TEST(2 - 1 == 1); } // Test in 'Physics' part FCF_TEST_DEFINE("Physics", "Mechanics", "Gravity") { FCF_TEST(9.8 > 0); } int main(int a_argc, char* a_argv[]) { // 1. Create an instance of fcf::NTest::Options fcf::NTest::Options options; // 2. Create a fcf::NTest::Options::Selector to filter by parts fcf::NTest::Options::Selector selector; // 3. Populate the parts vector // We want to run tests from both 'Math' and 'Physics' parts selector.parts.push_back("Math"); selector.parts.push_back("Physics"); // 4. Add the selector to the options options.selectors.push_back(selector); // 5. Run the tests bool error = false; fcf::NTest::run(options, &error); return error ? 1 : 0; }

Output:

Performing the test: "Math" -> "Arithmetic" -> "Addition" ... [SUCCESS] Test completed successfully (0.000`000`191 sec) Performing the test: "Math" -> "Arithmetic" -> "Subtraction" ... [SUCCESS] Test completed successfully (0.000`000`095 sec) Performing the test: "Physics" -> "Mechanics" -> "Gravity" ... [SUCCESS] Test completed successfully (0.000`000`096 sec) [SUCCESS] All tests were completed. Tests: 3 passed, 0 failed, 0 skipped, 3 total Duration: 0.000`000`382 sec

The test runner successfully identified and executed tests from the 'Math' and 'Physics' parts as specified in the parts vector.