MCPcopy Create free account
hub / github.com/apache/singa / OutputXmlTestInfo

Method OutputXmlTestInfo

test/gtest/gtest-all.cc:4767–4814  ·  view source on GitHub ↗

Prints an XML representation of a TestInfo object. TODO(wan): There is also value in printing properties with the plain printer.

Source from the content-addressed store, hash-verified

4765// Prints an XML representation of a TestInfo object.
4766// TODO(wan): There is also value in printing properties with the plain printer.
4767void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
4768 const char* test_case_name,
4769 const TestInfo& test_info) {
4770 const TestResult& result = *test_info.result();
4771 const std::string kTestcase = "testcase";
4772
4773 *stream << " <testcase";
4774 OutputXmlAttribute(stream, kTestcase, "name", test_info.name());
4775
4776 if (test_info.value_param() != NULL) {
4777 OutputXmlAttribute(stream, kTestcase, "value_param",
4778 test_info.value_param());
4779 }
4780 if (test_info.type_param() != NULL) {
4781 OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param());
4782 }
4783
4784 OutputXmlAttribute(stream, kTestcase, "status",
4785 test_info.should_run() ? "run" : "notrun");
4786 OutputXmlAttribute(stream, kTestcase, "time",
4787 FormatTimeInMillisAsSeconds(result.elapsed_time()));
4788 OutputXmlAttribute(stream, kTestcase, "classname", test_case_name);
4789 *stream << TestPropertiesAsXmlAttributes(result);
4790
4791 int failures = 0;
4792 for (int i = 0; i < result.total_part_count(); ++i) {
4793 const TestPartResult& part = result.GetTestPartResult(i);
4794 if (part.failed()) {
4795 if (++failures == 1) {
4796 *stream << ">\n";
4797 }
4798 const string location = internal::FormatCompilerIndependentFileLocation(
4799 part.file_name(), part.line_number());
4800 const string summary = location + "\n" + part.summary();
4801 *stream << " <failure message=\""
4802 << EscapeXmlAttribute(summary.c_str())
4803 << "\" type=\"\">";
4804 const string detail = location + "\n" + part.message();
4805 OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
4806 *stream << "</failure>\n";
4807 }
4808 }
4809
4810 if (failures == 0)
4811 *stream << " />\n";
4812 else
4813 *stream << " </testcase>\n";
4814}
4815
4816// Prints an XML representation of a TestCase object
4817void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,

Callers

nothing calls this directly

Calls 5

nameMethod · 0.80
elapsed_timeMethod · 0.80
total_part_countMethod · 0.80

Tested by

no test coverage detected