| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e1b71a8 commit b92ff7b
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3989,6 +3989,12 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { | |||
| 3989 | 3989 | static void OutputXmlTestSuiteForTestResult(::std::ostream* stream, | |
| 3990 | 3990 | const TestResult& result); | |
| 3991 | 3991 | ||
| 3992 | + // Streams a test case XML stanza containing the given test result. | ||
| 3993 | + // | ||
| 3994 | + // Requires: result.Failed() | ||
| 3995 | + static void OutputXmlTestCaseForTestResult(::std::ostream* stream, | ||
| 3996 | + const TestResult& result); | ||
| 3997 | + | ||
| 3992 | 3998 | // Streams an XML representation of a TestResult object. | |
| 3993 | 3999 | static void OutputXmlTestResult(::std::ostream* stream, | |
| 3994 | 4000 | const TestResult& result); | |
@@ -4236,6 +4242,15 @@ void XmlUnitTestResultPrinter::OutputXmlTestSuiteForTestResult( | |||
| 4236 | 4242 | FormatEpochTimeInMillisAsIso8601(result.start_timestamp())); | |
| 4237 | 4243 | *stream << ">"; | |
| 4238 | 4244 | ||
| 4245 | + OutputXmlTestCaseForTestResult(stream, result); | ||
| 4246 | + | ||
| 4247 | + // Complete the test suite. | ||
| 4248 | + *stream << " </testsuite>\n"; | ||
| 4249 | + } | ||
| 4250 | + | ||
| 4251 | + // Streams a test case XML stanza containing the given test result. | ||
| 4252 | + void XmlUnitTestResultPrinter::OutputXmlTestCaseForTestResult( | ||
| 4253 | + ::std::ostream* stream, const TestResult& result) { | ||
| 4239 | 4254 | // Output the boilerplate for a minimal test case with a single test. | |
| 4240 | 4255 | *stream << " <testcase"; | |
| 4241 | 4256 | OutputXmlAttribute(stream, "testcase", "name", ""); | |
@@ -4250,9 +4265,6 @@ void XmlUnitTestResultPrinter::OutputXmlTestSuiteForTestResult( | |||
| 4250 | 4265 | ||
| 4251 | 4266 | // Output the actual test result. | |
| 4252 | 4267 | OutputXmlTestResult(stream, result); | |
| 4253 | - | ||
| 4254 | - // Complete the test suite. | ||
| 4255 | - *stream << " </testsuite>\n"; | ||
| 4256 | 4268 | } | |
| 4257 | 4269 | ||
| 4258 | 4270 | // Prints an XML representation of a TestInfo object. | |
@@ -4379,6 +4391,10 @@ void XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream, | |||
| 4379 | 4391 | if (test_suite.GetTestInfo(i)->is_reportable()) | |
| 4380 | 4392 | OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i)); | |
| 4381 | 4393 | } | |
| 4394 | + if (test_suite.ad_hoc_test_result().Failed()) { | ||
| 4395 | + OutputXmlTestCaseForTestResult(stream, test_suite.ad_hoc_test_result()); | ||
| 4396 | + } | ||
| 4397 | + | ||
| 4382 | 4398 | *stream << " </" << kTestsuite << ">\n"; | |
| 4383 | 4399 | } | |
| 4384 | 4400 | ||
@@ -4518,6 +4534,12 @@ class JsonUnitTestResultPrinter : public EmptyTestEventListener { | |||
| 4518 | 4534 | static void OutputJsonTestSuiteForTestResult(::std::ostream* stream, | |
| 4519 | 4535 | const TestResult& result); | |
| 4520 | 4536 | ||
| 4537 | + // Streams a test case JSON stanza containing the given test result. | ||
| 4538 | + // | ||
| 4539 | + // Requires: result.Failed() | ||
| 4540 | + static void OutputJsonTestCaseForTestResult(::std::ostream* stream, | ||
| 4541 | + const TestResult& result); | ||
| 4542 | + | ||
| 4521 | 4543 | // Streams a JSON representation of a TestResult object. | |
| 4522 | 4544 | static void OutputJsonTestResult(::std::ostream* stream, | |
| 4523 | 4545 | const TestResult& result); | |
@@ -4688,6 +4710,15 @@ void JsonUnitTestResultPrinter::OutputJsonTestSuiteForTestResult( | |||
| 4688 | 4710 | } | |
| 4689 | 4711 | *stream << Indent(6) << "\"testsuite\": [\n"; | |
| 4690 | 4712 | ||
| 4713 | + OutputJsonTestCaseForTestResult(stream, result); | ||
| 4714 | + | ||
| 4715 | + // Finish the test suite. | ||
| 4716 | + *stream << "\n" << Indent(6) << "]\n" << Indent(4) << "}"; | ||
| 4717 | + } | ||
| 4718 | + | ||
| 4719 | + // Streams a test case JSON stanza containing the given test result. | ||
| 4720 | + void JsonUnitTestResultPrinter::OutputJsonTestCaseForTestResult( | ||
| 4721 | + ::std::ostream* stream, const TestResult& result) { | ||
| 4691 | 4722 | // Output the boilerplate for a new test case. | |
| 4692 | 4723 | *stream << Indent(8) << "{\n"; | |
| 4693 | 4724 | OutputJsonKey(stream, "testcase", "name", "", Indent(10)); | |
@@ -4704,9 +4735,6 @@ void JsonUnitTestResultPrinter::OutputJsonTestSuiteForTestResult( | |||
| 4704 | 4735 | ||
| 4705 | 4736 | // Output the actual test result. | |
| 4706 | 4737 | OutputJsonTestResult(stream, result); | |
| 4707 | - | ||
| 4708 | - // Finish the test suite. | ||
| 4709 | - *stream << "\n" << Indent(6) << "]\n" << Indent(4) << "}"; | ||
| 4710 | 4738 | } | |
| 4711 | 4739 | ||
| 4712 | 4740 | // Prints a JSON representation of a TestInfo object. | |
@@ -4851,6 +4879,16 @@ void JsonUnitTestResultPrinter::PrintJsonTestSuite( | |||
| 4851 | 4879 | OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i)); | |
| 4852 | 4880 | } | |
| 4853 | 4881 | } | |
| 4882 | + | ||
| 4883 | + // If there was a failure in the test suite setup or teardown include that in | ||
| 4884 | + // the output. | ||
| 4885 | + if (test_suite.ad_hoc_test_result().Failed()) { | ||
| 4886 | + if (comma) { | ||
| 4887 | + *stream << ",\n"; | ||
| 4888 | + } | ||
| 4889 | + OutputJsonTestCaseForTestResult(stream, test_suite.ad_hoc_test_result()); | ||
| 4890 | + } | ||
| 4891 | + | ||
| 4854 | 4892 | *stream << "\n" << kIndent << "]\n" << Indent(4) << "}"; | |
| 4855 | 4893 | } | |
| 4856 | 4894 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments