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

test from class fcf::NTest::Test

Property: test

Type: std::string

Class: fcf::NTest::Test

Package: fcfTest

File: test.hpp

Available from version: 1.2.2

The unique identifier/name of the test case.

The test property is the final level of the hierarchy. It is the unique identifier for an individual test case within its group.

The name is used in:

  • Filtering specific tests via the cmdRun command line interface.
  • Identifying tests in the console output and JUnit reports.
  • Defining specific execution orders for individual tests.

Example: Defining a Named Test Case

Demonstrating how to provide a unique name for a test using the FCF_TEST_DEFINE macro.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> // The third argument is the unique test name FCF_TEST_DEFINE("Math", "Basic", "AdditionTest") { const fcf::NTest::Test& test = fcf::NTest::state().test(); fcf::NTest::log() << "Testing addition (Test name: '" << test.test << "')..." << std::endl; FCF_TEST(1 + 1 == 2); } 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: "Math" -> "Basic" -> "AdditionTest" ... > Testing addition (Test name: 'AdditionTest')... [SUCCESS] Test completed successfully (0.000`005`156 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`005`156 sec