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

File class
From fcf::NTest::Options class

Type:
class fcf::NTest::Options::File

Owner class: fcf::NTest::Options

Package: fcfTest

File: test.hpp

Available from version: 1.0.1

A configuration structure representing a log file destination, specifying the file path and the output format.

The fcf::NTest::Options::File structure is used within the fcf::NTest::Options configuration to define specific file-based output targets. Each instance specifies a target file path and an associated logging format (such as 'default' or 'junit'), allowing the test runner to redirect logs to multiple files simultaneously with different formatting rules.

Properties
std::string file
- The path to the output log file.
std::string format
- Specifies the output format for a particular log file.

Example: Configuring Multiple Log Files

Demonstrates how to manually populate the Options structure to output test results to both a standard console-style log file and a JUnit XML report file.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> FCF_TEST_DEFINE("FileDemo", "Output", "MultiFileTest") { // Perform a simple assertion FCF_TEST(1 + 1 == 2); } int main(int a_argc, char* a_argv[]) { // Create an Options object fcf::NTest::Options options; // Configure the first file: a standard text log fcf::NTest::Options::File logFile; logFile.file = "test_results.log"; logFile.format = "default"; options.files.push_back(logFile); // Configure the second file: a JUnit XML report fcf::NTest::Options::File junitFile; junitFile.file = "report.xml"; junitFile.format = "junit"; options.files.push_back(junitFile); // Run the tests with the custom options bool error = false; fcf::NTest::run(options, &error); return error ? 1 : 0; }

Output:

Performing the test: "FileDemo" -> "Output" -> "MultiFileTest" ... [SUCCESS] Test completed successfully (0.000`000`191 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`000`191 sec

test_results.log file

Performing the test: "FileDemo" -> "Output" -> "MultiFileTest" ... [SUCCESS] Test completed successfully (0.000`000`191 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`000`191 sec

report.xml file

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