Class: fcf::NTest::State
Package: fcfTest
File:
test.hpp
(
link_to_the_declaration_in_the_file
,
link_to_the_implementation_in_the_file
)
Available from version: 1.2.2
Returns the number of tests currently selected for execution.
The testCount method provides a quick way to retrieve the total number of fcf::NTest::Test objects that are part of the current test selection.
This count reflects the number of tests that will be processed by the runner after all filters (parts, groups, tests, and ignore selectors) have been applied.
Result
size_t
- The number of selected tests.
Example: Getting the count of selected tests
Demonstrating how to check how many tests are scheduled to run.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
FCF_TEST_DEFINE("CountDemo", "Info", "CheckCount") {
// 1. Access the global state
fcf::NTest::State& currentState = fcf::NTest::state();
// 2. Get the number of selected tests
size_t count = currentState.testCount();
// 3. Output the result
fcf::NTest::log() << "Total tests to run: " << count << std::endl;
FCF_TEST(true);
}
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:
Performing the test: "CountDemo" -> "Info" -> "CheckCount" ...
> Total tests to run: 1
[SUCCESS] Test completed successfully (0.000`006`089 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`006`089 sec