Prints an XML summary of unit_test to output stream out.
| 3357 | |
| 3358 | // Prints an XML summary of unit_test to output stream out. |
| 3359 | void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, |
| 3360 | const UnitTest& unit_test) { |
| 3361 | const std::string kTestsuites = "testsuites"; |
| 3362 | |
| 3363 | *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
| 3364 | *stream << "<" << kTestsuites; |
| 3365 | |
| 3366 | OutputXmlAttribute(stream, kTestsuites, "tests", |
| 3367 | StreamableToString(unit_test.reportable_test_count())); |
| 3368 | OutputXmlAttribute(stream, kTestsuites, "failures", |
| 3369 | StreamableToString(unit_test.failed_test_count())); |
| 3370 | OutputXmlAttribute( |
| 3371 | stream, kTestsuites, "disabled", |
| 3372 | StreamableToString(unit_test.reportable_disabled_test_count())); |
| 3373 | OutputXmlAttribute(stream, kTestsuites, "errors", "0"); |
| 3374 | OutputXmlAttribute( |
| 3375 | stream, kTestsuites, "timestamp", |
| 3376 | FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp())); |
| 3377 | OutputXmlAttribute(stream, kTestsuites, "time", |
| 3378 | FormatTimeInMillisAsSeconds(unit_test.elapsed_time())); |
| 3379 | |
| 3380 | if (GTEST_FLAG(shuffle)) { |
| 3381 | OutputXmlAttribute(stream, kTestsuites, "random_seed", |
| 3382 | StreamableToString(unit_test.random_seed())); |
| 3383 | } |
| 3384 | |
| 3385 | *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result()); |
| 3386 | |
| 3387 | OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); |
| 3388 | *stream << ">\n"; |
| 3389 | |
| 3390 | for (int i = 0; i < unit_test.total_test_case_count(); ++i) { |
| 3391 | if (unit_test.GetTestCase(i)->reportable_test_count() > 0) |
| 3392 | PrintXmlTestCase(stream, *unit_test.GetTestCase(i)); |
| 3393 | } |
| 3394 | *stream << "</" << kTestsuites << ">\n"; |
| 3395 | } |
| 3396 | |
| 3397 | // Produces a string representing the test properties in a result as space |
| 3398 | // delimited XML attributes based on the property key="value" pairs. |
nothing calls this directly
no test coverage detected