Type: std::vector<fcf::NTest::Options::File>
Class: fcf::NTest::Options
Package: fcfTest
File: test.hpp
Available from version: 1.1.1
A list of files where test execution logs should be written, each associated with a specific format.
The files property allows you to redirect test execution logs to one or multiple files. Each entry in this vector is a fcf::NTest::Options::File structure, which pairs a file path with a specific output format.
This is particularly useful when you need to generate multiple reports simultaneously, such as a standard text log for human reading and a JUnit XML report for CI/CD integration.
Each File entry contains:
- file: The system path to the destination file.
- format: The name of the format to use (e.g., "default" or "junit").
Example: Logging to multiple files with different formats
Demonstrating how to configure fcf::NTest::Options::files to output both a human-readable log and a JUnit XML report to different files.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
// A simple test case for demonstration
FCF_TEST_DECLARE("Demo", "Files", "MultiLogTest") {
FCF_TEST(1 + 1 == 2);
}
int main(int a_argc, char* a_argv[]) {
// 1. Create an instance of fcf::NTest::Options
fcf::NTest::Options options;
// 2. Configure the 'files' property
// We want to save a standard log to 'console.log'
options.files.push_back({"console.log", "default"});
// And a JUnit XML report to 'results.xml'
options.files.push_back({"results.xml", "junit"});
// 3. Run the tests using the configured options
bool error = false;
fcf::NTest::run(options, &error);
// 4. Return status
return error ? 1 : 0;
}
Output:
Performing the test: "Demo" -> "Files" -> "MultiLogTest" ...
[SUCCESS] Test completed successfully (0.000`000`123 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`000`123 sec
After running the application, two files will be created: "console.log" (containing human-readable text) and "results.xml" (containing JUnit formatted XML).