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

tests from class fcf::NTest::Options::Selector

Property: tests = []

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

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

Package: fcfTest

File: test.hpp

Available from version: 1.1.12

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

The tests property is a collection of strings used to filter the execution of tests by their unique identifier (the 'Test' name level).

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

  • If the vector is empty, no filtering by test name is applied (all tests within the selected parts and groups will be included).
  • If it contains specific names, only the tests with those exact names 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 {"Test1", "Test2"}, only those two specific tests will run).

Example: Running specific individual tests

Demonstrating how to use the 'tests' vector to target only a few specific test cases by their names.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <vector> #include <string> // --- Test Suite Setup --- FCF_TEST_DEFINE("Math", "Arithmetic", "Addition") { FCF_TEST(1 + 1 == 2); } FCF_TEST_DEFINE("Math", "Arithmetic", "Subtraction") { FCF_TEST(2 - 1 == 1); } FCF_TEST_DEFINE("Math", "Geometry", "CircleArea") { FCF_TEST(true); } 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 fcf::NTest::Options::Selector selector; // 3. Populate the tests vector // We want to run ONLY 'Addition' and 'CircleArea' tests selector.tests.push_back("Addition"); selector.tests.push_back("CircleArea"); // 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`292 sec) Performing the test: "Math" -> "Geometry" -> "CircleArea" ... [SUCCESS] Test completed successfully (0.000`000`101 sec) [SUCCESS] All tests were completed. Tests: 2 passed, 0 failed, 0 skipped, 2 total Duration: 0.000`000`393 sec

The test runner executed only the two specified tests ('Addition' and 'CircleArea'), ignoring 'Subtraction' even though it belongs to the same 'Math' part.