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

file from class fcf::NTest::Options::File

Property: file

Type: std::string

Class: fcf::NTest::Options::File

Package: fcfTest

File: test.hpp

Available from version: 1.1.7

The path to the output log file.

The file property specifies the filesystem path where the test results should be written.

When combined with the format property, it allows you to direct different types of reports (e.g., standard text logs or JUnit XML files) to different physical files on your disk.

Note that the file will be opened in binary mode to ensure compatibility across different operating systems.

Example: Configuring multiple log files

Demonstrating how to configure the file property to save both a standard text log and a JUnit XML report to different locations.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <vector> #include <string> // --- Test Suite Setup --- FCF_TEST_DEFINE("Demo", "Group", "Test") { FCF_TEST(true); } int main(int a_argc, char* a_argv[]) { // 1. Create an instance of fcf::NTest::Options fcf::NTest::Options options; // 2. Configure a standard text log file fcf::NTest::Options::File textLog; textLog.file = "test_results.log"; textLog.format = "default"; options.files.push_back(textLog); // 3. Configure a JUnit XML report file fcf::NTest::Options::File junitLog; junitLog.file = "report.xml"; junitLog.format = "junit"; options.files.push_back(junitLog); // 4. Run the tests bool error = false; fcf::NTest::run(options, &error); return error ? 1 : 0; }

Output:

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

The test runner has created two files: test_results.log containing the human-readable output and report.xml containing the machine-readable JUnit XML data.

test_results.log file

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

report.xml file

<?xml version="1.0" encoding="UTF-8"?> <testsuites tests="1" failure="0" skipped="0" time="0.000000249"> <testsuite name="Demo/Group" tests="1" failure="0" skipped="0" time="0.000000249"> <testcase classname="Demo/Group" name="Test" time="0.000000249"/> </testsuite> </testsuites>