The class XmlOutputter (see Figure C-36) is a subclass of Outputter . It gets test results from a TestResultCollector and outputs them in XML format to an output stream. The write( ) method is called to produce the output, rather than calling the other output methods directly.
XmlOutputter defines a nested class named Node representing an XML node.
XmlOutputter belongs to the namespace CppUnit . It is declared in XmlOutputter.h and implemented in XmlOutputter.cpp .
class XmlOutputter : public Outputter
Constructs an XmlOutputter to get test results from result and output them to stream . The default encoding is ASCII, also known as Latin-1 or ISO 8859-1.
Creates an XML node representing the test failure and adds it to testsNode . Also calls addFailureLocation() if the test failure has a valid SourceLine .
Adds the test failures from failedTests to rootNode using addFailedTest( ) .
Creates an XML node representing the test failure location and adds it to testNode .
Creates an XML node containing the number of tests, number of failures, and number of errors, and adds it to rootNode .
Creates an XML node representing a test success and adds it to testsNode .
Adds the successful tests from the TestResultCollector to rootNode using addSucessfulTest( ) .
Creates a Node and adds the test results to it using addFailedTests( ) , addSucessfulTests( ) , and addStatistics() .
A method that writes the XML prolog (header), which includes the XML version (1.0) and the encoding type.
A method that writes the body of the XML document. Calls makeRootNode( ) and writes the resulting Node to the output stream as a string .
Method called to write the test results to the output stream as an XML document. Calls writeProlog( ) and writeTestsResult( ) .
A protected method to get the test failures from the TestResultCollector and add them to failedTests .
A copy constructor, scoped private to prevent its use.
A copy operator, scoped private to prevent its use.
Defines the type FailedTests as a map of Test objects to TestFailure objects.
The encoding type to be written in the XML prolog ( private ).
The TestResultCollector passed in the constructor ( private ).
The output stream passed in the constructor ( private ).