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

fcf::NTest::cmdList() function

Package: fcfTest

File: test.hpp

Available from version: 1.0.1

Outputs a hierarchical list of all registered tests to the standard output (stdout), following the structure: Part > Group > Test.

The fcf::NTest::cmdList function provides a way to inspect the current test registry. It iterates through all registered tests stored in the global fcf::NTest::NDetails::Storage and prints them in a human-readable hierarchical format. This is useful for verifying test organization and ensuring that all intended tests are correctly registered under their respective parts and groups.

Detailed description

The function performs the following actions:

  • Retrieves the current set of all registered tests.
  • Iterates through the tests in their sorted order (determined by fcf::NTest::NDetails::Test::operator<).
  • Prints each test to std::cout using the format: "Part" -> "Group" -> "Test".

Example: Integration with Command Line Interface (CLI)

The most common use case is calling fcf::NTest::cmdList when the --test-list flag is detected during command-line argument parsing.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> FCF_TEST_DECLARE("Math", "Arithmetic", "Addition"){ // internal testing code ... } FCF_TEST_DECLARE("Math", "Arithmetic", "Subtraction"){ // internal testing code ... } FCF_TEST_DECLARE("Network", "Connection", "Ping"){ // internal testing code ... } int main(int argc, char* argv[]) { bool error; // If --test-list is passed, cmdRun will call cmdList() and exit fcf::NTest::cmdRun(argc, argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

List of tests: "Math" -> "Arithmetic" -> "Addition" "Math" -> "Arithmetic" -> "Subtraction" "Network" -> "Connection" -> "Ping"

Launch the application with options: ./my_test_executable --test-list