Index: base/test/gtest_xml_unittest_result_printer.cc |
diff --git a/base/test/gtest_xml_unittest_result_printer.cc b/base/test/gtest_xml_unittest_result_printer.cc |
index 192c228e2dd28a602dbe54f81dd4e28d487df40e..6ce4fdecf3fcddd2487f5e529e56f86d00f1a2e3 100644 |
--- a/base/test/gtest_xml_unittest_result_printer.cc |
+++ b/base/test/gtest_xml_unittest_result_printer.cc |
@@ -4,6 +4,7 @@ |
#include "base/test/gtest_xml_unittest_result_printer.h" |
+#include "base/base64.h" |
#include "base/files/file_util.h" |
#include "base/logging.h" |
#include "base/time/time.h" |
@@ -64,6 +65,9 @@ void XmlUnitTestResultPrinter::OnTestEnd(const testing::TestInfo& test_info) { |
fprintf(output_file_, |
" <failure message=\"\" type=\"\"></failure>\n"); |
} |
+ for (int i = 0; i < test_info.result()->total_part_count(); ++i) { |
+ WriteTestPartResult(test_info.result()->GetTestPartResult(i)); |
+ } |
fprintf(output_file_, " </testcase>\n"); |
fflush(output_file_); |
} |
@@ -74,4 +78,34 @@ void XmlUnitTestResultPrinter::OnTestCaseEnd( |
fflush(output_file_); |
} |
+void XmlUnitTestResultPrinter::WriteTestPartResult( |
+ const testing::TestPartResult& test_part_result) { |
+ const char* type = "unknown"; |
+ switch (test_part_result.type()) { |
+ case testing::TestPartResult::kSuccess: |
+ type = "success"; |
+ break; |
+ case testing::TestPartResult::kNonFatalFailure: |
+ type = "failure"; |
+ break; |
+ case testing::TestPartResult::kFatalFailure: |
+ type = "fatal_failure"; |
+ break; |
+ } |
+ std::string summary = test_part_result.summary(); |
+ std::string summary_encoded; |
+ Base64Encode(summary, &summary_encoded); |
+ std::string message = test_part_result.message(); |
+ std::string message_encoded; |
+ Base64Encode(message, &message_encoded); |
+ fprintf(output_file_, |
+ " <x-test-result-part type=\"%s\" file=\"%s\" line=\"%d\">\n" |
+ " <summary>%s</summary>\n" |
+ " <message>%s</message>\n" |
+ " </x-test-result-part>\n", |
+ type, test_part_result.file_name(), test_part_result.line_number(), |
+ summary_encoded.c_str(), message_encoded.c_str()); |
+ fflush(output_file_); |
+} |
+ |
} // namespace base |