Prints an XML summary of unit_test to output stream out.
| 4841 | |
| 4842 | // Prints an XML summary of unit_test to output stream out. |
| 4843 | void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, |
| 4844 | const UnitTest& unit_test) { |
| 4845 | const std::string kTestsuites = "testsuites"; |
| 4846 | |
| 4847 | *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
| 4848 | *stream << "<" << kTestsuites; |
| 4849 | |
| 4850 | OutputXmlAttribute(stream, kTestsuites, "tests", |
| 4851 | StreamableToString(unit_test.reportable_test_count())); |
| 4852 | OutputXmlAttribute(stream, kTestsuites, "failures", |
| 4853 | StreamableToString(unit_test.failed_test_count())); |
| 4854 | OutputXmlAttribute( |
| 4855 | stream, kTestsuites, "disabled", |
| 4856 | StreamableToString(unit_test.reportable_disabled_test_count())); |
| 4857 | OutputXmlAttribute(stream, kTestsuites, "errors", "0"); |
| 4858 | OutputXmlAttribute( |
| 4859 | stream, kTestsuites, "timestamp", |
| 4860 | FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp())); |
| 4861 | OutputXmlAttribute(stream, kTestsuites, "time", |
| 4862 | FormatTimeInMillisAsSeconds(unit_test.elapsed_time())); |
| 4863 | |
| 4864 | if (GTEST_FLAG(shuffle)) { |
| 4865 | OutputXmlAttribute(stream, kTestsuites, "random_seed", |
| 4866 | StreamableToString(unit_test.random_seed())); |
| 4867 | } |
| 4868 | |
| 4869 | *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result()); |
| 4870 | |
| 4871 | OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); |
| 4872 | *stream << ">\n"; |
| 4873 | |
| 4874 | for (int i = 0; i < unit_test.total_test_case_count(); ++i) { |
| 4875 | if (unit_test.GetTestCase(i)->reportable_test_count() > 0) |
| 4876 | PrintXmlTestCase(stream, *unit_test.GetTestCase(i)); |
| 4877 | } |
| 4878 | *stream << "</" << kTestsuites << ">\n"; |
| 4879 | } |
| 4880 | |
| 4881 | // Produces a string representing the test properties in a result as space |
| 4882 | // delimited XML attributes based on the property key="value" pairs. |
nothing calls this directly
no test coverage detected