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

format from class fcf::NTest::Options

Property: format = "default"

Type: std::string

Class: fcf::NTest::Options

Package: fcfTest

File: test.hpp

Available from version: 1.1.1

Output format for the test results (e.g., "default" or "junit").

The format property determines the visual representation of the test execution results. It allows users to switch between a human-readable console output and machine-readable formats suitable for CI/CD pipelines.

Supported formats include:

  • "default": A standard, human-friendly output designed for console viewing.
  • "junit": An XML-based format following the JUnit schema, ideal for integration with automated testing tools and build servers.

Example: Specifying a custom output format via Options

Demonstrating how to manually configure the fcf::NTest::Options::format property to generate JUnit XML reports.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> // A simple test case to be included in the report FCF_TEST_DECLARE("FormatDemo", "Output", "JUnitTest") { fcf::NTest::log() << "This test is part of a JUnit report." << std::endl; FCF_TEST(true); } int main(int a_argc, char* a_argv[]) { // 1. Create an instance of fcf::NTest::Options fcf::NTest::Options options; // 2. Set the desired output format to "junit" options.format = "junit"; // 3. Run the tests with the configured options bool error = false; fcf::NTest::run(options, &error); return error ? 1 : 0; }

Output:

<?xml version="1.0" encoding="UTF-8"?> <testsuites tests="1" failure="0" skipped="0" time="0.000006051"> <testsuite name="FormatDemo/Output" tests="1" failure="0" skipped="0" time="0.000006051"> <testcase classname="FormatDemo/Output" name="JUnitTest" time="0.000006051"/> </testsuite> </testsuites>