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

noBreak from class fcf::NTest::Options

Property: noBreak = false

Type: bool

Class: fcf::NTest::Options

Package: fcfTest

File: test.hpp

Available from version: 1.1.1

Determines whether the test execution should continue after a test failure.

The noBreak property controls the execution flow of the test runner when an assertion fails.

  • If false (default): The test runner will stop immediately after the first encountered test failure. This is useful for debugging and quick feedback.
  • If true: The test runner will log the error and proceed to execute the remaining tests in the suite. This is ideal for generating full reports of all failures in a single run.

Example: Continuing test execution after failures

Demonstrating how to configure the fcf::NTest::Options::noBreak property to ensure that all tests are executed even if some of them fail.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> // First test that will fail FCF_TEST_DECLARE("Demo", "FailureGroup", "FailingTest") { FCF_TEST(1 == 2, 1, 2); } // Second test that would be skipped if noBreak was false FCF_TEST_DECLARE("Demo", "SuccessGroup", "PassingTest") { FCF_TEST(1 == 1); } int main(int a_argc, char* a_argv[]) { // 1. Create an instance of fcf::NTest::Options fcf::NTest::Options options; // 2. Enable the 'noBreak' mode so that the runner doesn't stop on the first error options.noBreak = true; // 3. Run the tests with the configured options bool error = false; fcf::NTest::run(options, &error); // 4. Return non-zero if any test failed return error ? 1 : 0; }

Output:

Performing the test: "Demo" -> "FailureGroup" -> "FailingTest" ... Test error: 1 == 2 [FILE: PATH/main.cpp:6] Values: 1: 1 2: 2 [FAILED] Test failed (0.000`047`267 sec) Performing the test: "Demo" -> "SuccessGroup" -> "PassingTest" ... [SUCCESS] Test completed successfully (0.000`000`182 sec) [FAILED] Testing completed with failures. Tests: 1 passed, 1 failed, 0 skipped, 2 total Duration: 0.000`047`449 sec

Because noBreak was set to true, the "PassingTest" was executed despite the previous failure.