MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / OutputXmlTestInfo

Method OutputXmlTestInfo

tests/external/gmock-1.7.0/gtest/src/gtest.cc:3283–3330  ·  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

3281// Prints an XML representation of a TestInfo object.
3282// TODO(wan): There is also value in printing properties with the plain printer.
3283void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
3284 const char* test_case_name,
3285 const TestInfo& test_info) {
3286 const TestResult& result = *test_info.result();
3287 const std::string kTestcase = "testcase";
3288
3289 *stream << " <testcase";
3290 OutputXmlAttribute(stream, kTestcase, "name", test_info.name());
3291
3292 if (test_info.value_param() != NULL) {
3293 OutputXmlAttribute(stream, kTestcase, "value_param",
3294 test_info.value_param());
3295 }
3296 if (test_info.type_param() != NULL) {
3297 OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param());
3298 }
3299
3300 OutputXmlAttribute(stream, kTestcase, "status",
3301 test_info.should_run() ? "run" : "notrun");
3302 OutputXmlAttribute(stream, kTestcase, "time",
3303 FormatTimeInMillisAsSeconds(result.elapsed_time()));
3304 OutputXmlAttribute(stream, kTestcase, "classname", test_case_name);
3305 *stream << TestPropertiesAsXmlAttributes(result);
3306
3307 int failures = 0;
3308 for (int i = 0; i < result.total_part_count(); ++i) {
3309 const TestPartResult& part = result.GetTestPartResult(i);
3310 if (part.failed()) {
3311 if (++failures == 1) {
3312 *stream << ">\n";
3313 }
3314 const string location = internal::FormatCompilerIndependentFileLocation(
3315 part.file_name(), part.line_number());
3316 const string summary = location + "\n" + part.summary();
3317 *stream << " <failure message=\""
3318 << EscapeXmlAttribute(summary.c_str())
3319 << "\" type=\"\">";
3320 const string detail = location + "\n" + part.message();
3321 OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
3322 *stream << "</failure>\n";
3323 }
3324 }
3325
3326 if (failures == 0)
3327 *stream << " />\n";
3328 else
3329 *stream << " </testcase>\n";
3330}
3331
3332// Prints an XML representation of a TestCase object
3333void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,

Callers

nothing calls this directly

Calls 5

summaryMethod · 0.80
elapsed_timeMethod · 0.45
total_part_countMethod · 0.45

Tested by

no test coverage detected