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

active() method from fcf::NTest::State class

bool active() const

Class: fcf::NTest::State

Package: fcfTest

File: test.hpp

Available from version: 1.2.4

Checks whether a test is currently being executed.

The active method returns a boolean value indicating whether the test runner is currently in the middle of executing a test case.

Result
bool
- True if a test is currently active, false otherwise.

Example: Checking test activity status

Demonstrating how to check if the framework is currently running a test.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> FCF_TEST_BEFORE_DEFINE("Status", "Check", "ActiveTest", fcf::NTest::FL_TEST) { // Check if the state reports as active bool activeState = fcf::NTest::state().active(); if (!activeState) { fcf::NTest::log() << "Confirmed: Test is not currently active in the fixture." << std::endl; } else { FCF_TEST(false, "Error: Test is active in the fixture!"); } } FCF_TEST_AFTER_DEFINE("Status", "Check", "ActiveTest", fcf::NTest::FL_TEST) { // Check if the state reports as active bool activeState = fcf::NTest::state().active(); if (!activeState) { fcf::NTest::log() << "Confirmed: Test is not currently active in the fixture." << std::endl; } else { FCF_TEST(false, "Error: Test is active in the fixture!"); } } FCF_TEST_DEFINE("Status", "Check", "ActiveTest") { // Check if the state reports as active bool activeState = fcf::NTest::state().active(); if (activeState) { fcf::NTest::log() << "Confirmed: Test is currently active." << std::endl; } else { FCF_TEST(false, "Error: Test is not active!"); } } int main(int a_argc, char* a_argv[]) { bool error = false; fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

> Confirmed: Test is not currently active in the fixture. Performing the test: "Status" -> "Check" -> "ActiveTest" ... > Confirmed: Test is currently active. [SUCCESS] Test completed successfully (0.000`003`647 sec) > Confirmed: Test is not currently active in the fixture. [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`003`647 sec