Prints an XML representation of a TestInfo object. TODO(wan): There is also value in printing properties with the plain printer.
| 5063 | // Prints an XML representation of a TestInfo object. |
| 5064 | // TODO(wan): There is also value in printing properties with the plain printer. |
| 5065 | void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, |
| 5066 | const char* test_case_name, |
| 5067 | const TestInfo& test_info) { |
| 5068 | const TestResult& result = *test_info.result(); |
| 5069 | const std::string kTestcase = "testcase"; |
| 5070 | |
| 5071 | *stream << " <testcase"; |
| 5072 | OutputXmlAttribute(stream, kTestcase, "name", test_info.name()); |
| 5073 | |
| 5074 | if (test_info.value_param() != NULL) { |
| 5075 | OutputXmlAttribute(stream, kTestcase, "value_param", |
| 5076 | test_info.value_param()); |
| 5077 | } |
| 5078 | if (test_info.type_param() != NULL) { |
| 5079 | OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param()); |
| 5080 | } |
| 5081 | |
| 5082 | OutputXmlAttribute(stream, kTestcase, "status", |
| 5083 | test_info.should_run() ? "run" : "notrun"); |
| 5084 | OutputXmlAttribute(stream, kTestcase, "time", |
| 5085 | FormatTimeInMillisAsSeconds(result.elapsed_time())); |
| 5086 | OutputXmlAttribute(stream, kTestcase, "classname", test_case_name); |
| 5087 | *stream << TestPropertiesAsXmlAttributes(result); |
| 5088 | |
| 5089 | int failures = 0; |
| 5090 | for (int i = 0; i < result.total_part_count(); ++i) { |
| 5091 | const BaseTestPartResult* part = result.GetTestPartResult(i); |
| 5092 | if (part->type() != BaseTestPartResult::kSuccess) { |
| 5093 | if (++failures == 1) { |
| 5094 | *stream << ">\n"; |
| 5095 | } |
| 5096 | UnitTest::GetInstance()->GetStoredResultEventListener()->OutputXmlTestPartResult(stream, part); |
| 5097 | } |
| 5098 | } |
| 5099 | |
| 5100 | if (failures == 0) |
| 5101 | *stream << " />\n"; |
| 5102 | else |
| 5103 | *stream << " </testcase>\n"; |
| 5104 | } |
| 5105 | |
| 5106 | // Prints an XML representation of a TestPartResult object. |
| 5107 | void XmlUnitTestResultPrinter::OutputXmlTestPartResult(::std::ostream* stream, |
nothing calls this directly
no test coverage detected