MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / writeXmlReport

Function writeXmlReport

Source/Falcor/Testing/UnitTest.cpp:170–212  ·  view source on GitHub ↗

* Write a test report in JUnit's XML format. * @param[in] path File path. * @param[in] report List of tests/results. */

Source from the content-addressed store, hash-verified

168 * @param[in] report List of tests/results.
169 */
170inline void writeXmlReport(const std::filesystem::path& path, const std::vector<std::pair<Test, TestResult>>& report)
171{
172 pugi::xml_document doc;
173
174 pugi::xml_node testsuitesNode = doc.append_child("testsuites");
175 testsuitesNode.append_attribute("name").set_value("Unit Tests");
176
177 // Split reports into suites.
178 std::map<std::string, std::vector<std::pair<Test, TestResult>>> reportBySuite;
179 for (const auto& item : report)
180 reportBySuite[item.first.suiteName].push_back(item);
181
182 for (const auto& [suiteName, suiteReport] : reportBySuite)
183 {
184 pugi::xml_node testsuiteNode = testsuitesNode.append_child("testsuite");
185 testsuiteNode.append_attribute("name").set_value(suiteName.c_str());
186
187 for (const auto& [test, result] : suiteReport)
188 {
189 pugi::xml_node testcaseNode = testsuiteNode.append_child("testcase");
190 testcaseNode.append_attribute("name").set_value(test.name.c_str());
191 testcaseNode.append_attribute("time").set_value(result.elapsedMS / 1000.0);
192
193 switch (result.status)
194 {
195 case TestResult::Status::Passed:
196 break;
197 case TestResult::Status::Skipped:
198 testcaseNode.append_child("skipped");
199 break;
200 case TestResult::Status::Failed:
201 default:
202 {
203 std::string message = joinStrings(result.messages, "\n");
204 testcaseNode.append_child("failure").append_attribute("message").set_value(message.c_str());
205 }
206 break;
207 }
208 }
209 }
210
211 doc.save_file(path.native().c_str());
212}
213
214inline TestResult runTest(const Test& test, DevicePool& devicePool)
215{

Callers 1

runTestsSerialFunction · 0.85

Calls 3

joinStringsFunction · 0.85
set_valueMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected