@ -3989,6 +3989,12 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
static void OutputXmlTestSuiteForTestResult ( : : std : : ostream * stream ,
static void OutputXmlTestSuiteForTestResult ( : : std : : ostream * stream ,
const TestResult & result ) ;
const TestResult & result ) ;
// Streams a test case XML stanza containing the given test result.
//
// Requires: result.Failed()
static void OutputXmlTestCaseForTestResult ( : : std : : ostream * stream ,
const TestResult & result ) ;
// Streams an XML representation of a TestResult object.
// Streams an XML representation of a TestResult object.
static void OutputXmlTestResult ( : : std : : ostream * stream ,
static void OutputXmlTestResult ( : : std : : ostream * stream ,
const TestResult & result ) ;
const TestResult & result ) ;
@ -4236,6 +4242,15 @@ void XmlUnitTestResultPrinter::OutputXmlTestSuiteForTestResult(
FormatEpochTimeInMillisAsIso8601 ( result . start_timestamp ( ) ) ) ;
FormatEpochTimeInMillisAsIso8601 ( result . start_timestamp ( ) ) ) ;
* stream < < " > " ;
* stream < < " > " ;
OutputXmlTestCaseForTestResult ( stream , result ) ;
// Complete the test suite.
* stream < < " </testsuite> \n " ;
}
// Streams a test case XML stanza containing the given test result.
void XmlUnitTestResultPrinter : : OutputXmlTestCaseForTestResult (
: : std : : ostream * stream , const TestResult & result ) {
// Output the boilerplate for a minimal test case with a single test.
// Output the boilerplate for a minimal test case with a single test.
* stream < < " <testcase " ;
* stream < < " <testcase " ;
OutputXmlAttribute ( stream , " testcase " , " name " , " " ) ;
OutputXmlAttribute ( stream , " testcase " , " name " , " " ) ;
@ -4250,9 +4265,6 @@ void XmlUnitTestResultPrinter::OutputXmlTestSuiteForTestResult(
// Output the actual test result.
// Output the actual test result.
OutputXmlTestResult ( stream , result ) ;
OutputXmlTestResult ( stream , result ) ;
// Complete the test suite.
* stream < < " </testsuite> \n " ;
}
}
// Prints an XML representation of a TestInfo object.
// Prints an XML representation of a TestInfo object.
@ -4379,6 +4391,10 @@ void XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream,
if ( test_suite . GetTestInfo ( i ) - > is_reportable ( ) )
if ( test_suite . GetTestInfo ( i ) - > is_reportable ( ) )
OutputXmlTestInfo ( stream , test_suite . name ( ) , * test_suite . GetTestInfo ( i ) ) ;
OutputXmlTestInfo ( stream , test_suite . name ( ) , * test_suite . GetTestInfo ( i ) ) ;
}
}
if ( test_suite . ad_hoc_test_result ( ) . Failed ( ) ) {
OutputXmlTestCaseForTestResult ( stream , test_suite . ad_hoc_test_result ( ) ) ;
}
* stream < < " </ " < < kTestsuite < < " > \n " ;
* stream < < " </ " < < kTestsuite < < " > \n " ;
}
}
@ -4518,6 +4534,12 @@ class JsonUnitTestResultPrinter : public EmptyTestEventListener {
static void OutputJsonTestSuiteForTestResult ( : : std : : ostream * stream ,
static void OutputJsonTestSuiteForTestResult ( : : std : : ostream * stream ,
const TestResult & result ) ;
const TestResult & result ) ;
// Streams a test case JSON stanza containing the given test result.
//
// Requires: result.Failed()
static void OutputJsonTestCaseForTestResult ( : : std : : ostream * stream ,
const TestResult & result ) ;
// Streams a JSON representation of a TestResult object.
// Streams a JSON representation of a TestResult object.
static void OutputJsonTestResult ( : : std : : ostream * stream ,
static void OutputJsonTestResult ( : : std : : ostream * stream ,
const TestResult & result ) ;
const TestResult & result ) ;
@ -4688,6 +4710,15 @@ void JsonUnitTestResultPrinter::OutputJsonTestSuiteForTestResult(
}
}
* stream < < Indent ( 6 ) < < " \" testsuite \" : [ \n " ;
* stream < < Indent ( 6 ) < < " \" testsuite \" : [ \n " ;
OutputJsonTestCaseForTestResult ( stream , result ) ;
// Finish the test suite.
* stream < < " \n " < < Indent ( 6 ) < < " ] \n " < < Indent ( 4 ) < < " } " ;
}
// Streams a test case JSON stanza containing the given test result.
void JsonUnitTestResultPrinter : : OutputJsonTestCaseForTestResult (
: : std : : ostream * stream , const TestResult & result ) {
// Output the boilerplate for a new test case.
// Output the boilerplate for a new test case.
* stream < < Indent ( 8 ) < < " { \n " ;
* stream < < Indent ( 8 ) < < " { \n " ;
OutputJsonKey ( stream , " testcase " , " name " , " " , Indent ( 10 ) ) ;
OutputJsonKey ( stream , " testcase " , " name " , " " , Indent ( 10 ) ) ;
@ -4704,9 +4735,6 @@ void JsonUnitTestResultPrinter::OutputJsonTestSuiteForTestResult(
// Output the actual test result.
// Output the actual test result.
OutputJsonTestResult ( stream , result ) ;
OutputJsonTestResult ( stream , result ) ;
// Finish the test suite.
* stream < < " \n " < < Indent ( 6 ) < < " ] \n " < < Indent ( 4 ) < < " } " ;
}
}
// Prints a JSON representation of a TestInfo object.
// Prints a JSON representation of a TestInfo object.
@ -4851,6 +4879,16 @@ void JsonUnitTestResultPrinter::PrintJsonTestSuite(
OutputJsonTestInfo ( stream , test_suite . name ( ) , * test_suite . GetTestInfo ( i ) ) ;
OutputJsonTestInfo ( stream , test_suite . name ( ) , * test_suite . GetTestInfo ( i ) ) ;
}
}
}
}
// If there was a failure in the test suite setup or teardown include that in
// the output.
if ( test_suite . ad_hoc_test_result ( ) . Failed ( ) ) {
if ( comma ) {
* stream < < " , \n " ;
}
OutputJsonTestCaseForTestResult ( stream , test_suite . ad_hoc_test_result ( ) ) ;
}
* stream < < " \n " < < kIndent < < " ] \n " < < Indent ( 4 ) < < " } " ;
* stream < < " \n " < < kIndent < < " ] \n " < < Indent ( 4 ) < < " } " ;
}
}