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

ignoreSelectors from class fcf::NTest::Options

Property: ignoreSelectors = []

Type: std::vector<fcf::NTest::Options::Selector>

Class: fcf::NTest::Options

Package: fcfTest

File: test.hpp

Available from version: 1.1.12

A list of selectors used to exclude specific tests from the execution.

The ignoreSelectors property is a collection of fcf::NTest::Options::Selector objects used to filter out tests from the execution suite.

While selectors define what should be run, ignoreSelectors define what must not be run.

Filtering logic works as follows:

  1. The runner first identifies all tests that match the criteria in selectors (using OR logic between selectors).
  2. Then, it removes any test that matches any of the criteria in ignoreSelectors (using OR logic between ignore-selectors).

A selector in this list can filter by parts, tests.

Example: Excluding specific tests from a selection

Demonstrating how to use fcf::NTest::Options::ignoreSelectors to run all tests in a part except for a specific group or a single test.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <vector> #include <string> // 1. Test in 'Math' -> 'Algebra' -> 'Add' FCF_TEST_DECLARE("Math", "Algebra", "Add") { FCF_TEST(true); } // 2. Test in 'Math' -> 'Algebra' -> 'Sub' FCF_TEST_DECLARE("Math", "Algebra", "Sub") { FCF_TEST(true); } // 3. Test in 'Math' -> 'Geometry' -> 'Area' FCF_TEST_DECLARE("Math", "Geometry", "Area") { FCF_TEST(true); } int main(int a_argc, char* a_argv[]) { // 1. Create an instance of fcf::NTest::Options fcf::NTest::Options options; // 2. Select all tests in the 'Math' part fcf::NTest::Options::Selector mathSelector; mathSelector.parts.push_back("Math"); options.selectors.push_back(mathSelector); // 3. Create an ignore selector to exclude the 'Geometry' group fcf::NTest::Options::Selector ignoreGeometry; ignoreGeometry.groups.push_back("Geometry"); // 4. Add the ignore selector to the options.ignoreSelectors list options.ignoreSelectors.push_back(ignoreGeometry); // 5. Run the tests. Only 'Algebra' tests should run. bool error = false; fcf::NTest::run(options, &error); return error ? 1 : 0; }

Output:

Performing the test: "Math" -> "Algebra" -> "Add" ... [SUCCESS] Test completed successfully (0.000`001`234 sec) Performing the test: "Math" -> "Algebra" -> "Sub" ... [SUCCESS] Test completed successfully (0.000`000`876 sec) [SUCCESS] All tests were completed. Tests: 2 passed, 0 failed, 0 skipped, 2 total Duration: 0.000`002`110 sec

Even though 'Geometry' tests belong to the 'Math' part, they were not executed because the 'Geometry' group was added to the ignoreSelectors list.