CppUnit project page FAQ

Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
XmlOutputter Class Reference

Outputs a TestResultCollector in XML format. More...

#include <XmlOutputter.h>

Inheritance diagram for XmlOutputter:
Inheritance graph
[legend]
Collaboration diagram for XmlOutputter:
Collaboration graph
[legend]

Public Types

typedef std::map< Test *, TestFailure *, std::less< Test * > > FailedTests
 

Public Member Functions

 XmlOutputter (TestResultCollector *result, OStream &stream, const std::string &encoding=std::string("ISO-8859-1"))
 Constructs a XmlOutputter object. More...
 
virtual ~XmlOutputter ()
 Destructor. More...
 
virtual void addHook (XmlOutputterHook *hook)
 Adds the specified hook to the outputter. More...
 
virtual void removeHook (XmlOutputterHook *hook)
 Removes the specified hook from the outputter. More...
 
virtual void write ()
 Writes the specified result as an XML document to the stream. More...
 
virtual void setStyleSheet (const std::string &styleSheet)
 Sets the XSL style sheet used. More...
 
virtual void setStandalone (bool standalone)
 set the output document as standalone or not. More...
 
virtual void setRootNode ()
 Sets the root element and adds its children. More...
 
virtual void addFailedTests (FailedTests &failedTests, XmlElement *rootNode)
 
virtual void addSuccessfulTests (FailedTests &failedTests, XmlElement *rootNode)
 
virtual void addStatistics (XmlElement *rootNode)
 Adds the statics element to the root node. More...
 
virtual void addFailedTest (Test *test, TestFailure *failure, int testNumber, XmlElement *testsNode)
 Adds a failed test to the failed tests node. Creates a new element containing datas about the failed test, and adds it to the failed tests element. Then, for all hooks, call failTestAdded(). More...
 
virtual void addFailureLocation (TestFailure *failure, XmlElement *testElement)
 
virtual void addSuccessfulTest (Test *test, int testNumber, XmlElement *testsNode)
 Adds a successful test to the successful tests node. Creates a new element containing datas about the successful test, and adds it to the successful tests element. Then, for all hooks, call successfulTestAdded(). More...
 
- Public Member Functions inherited from Outputter
virtual ~Outputter ()
 Destructor. More...
 

Protected Types

typedef std::deque< XmlOutputterHook * > Hooks
 

Protected Member Functions

virtual void fillFailedTestsMap (FailedTests &failedTests)
 

Protected Attributes

TestResultCollectorm_result
 
OStreamm_stream
 
std::string m_encoding
 
std::string m_styleSheet
 
XmlDocumentm_xml
 
Hooks m_hooks
 

Private Member Functions

 XmlOutputter (const XmlOutputter &copy)
 Prevents the use of the copy constructor. More...
 
void operator= (const XmlOutputter &copy)
 Prevents the use of the copy operator. More...
 

Detailed Description

Outputs a TestResultCollector in XML format.

Save the test result as a XML stream.

Additional datas can be added to the XML document using XmlOutputterHook. Hook are not owned by the XmlOutputter. They should be valid until destruction of the XmlOutputter. They can be removed with removeHook().

See also
XmlDocument, XmlElement, XmlOutputterHook.

Member Typedef Documentation

◆ FailedTests

typedef std::map<Test *,TestFailure*, std::less<Test*> > XmlOutputter::FailedTests

◆ Hooks

typedef std::deque<XmlOutputterHook *> XmlOutputter::Hooks
protected

Constructor & Destructor Documentation

◆ XmlOutputter() [1/2]

CPPUNIT_NS_BEGIN XmlOutputter::XmlOutputter ( TestResultCollector result,
OStream stream,
const std::string &  encoding = std::string("ISO-8859-1") 
)

Constructs a XmlOutputter object.

Parameters
resultResult of the test run.
streamStream used to output the XML output.
encodingEncoding used in the XML file (default is Latin-1).

◆ ~XmlOutputter()

XmlOutputter::~XmlOutputter ( )
virtual

Destructor.

◆ XmlOutputter() [2/2]

XmlOutputter::XmlOutputter ( const XmlOutputter copy)
private

Prevents the use of the copy constructor.

Member Function Documentation

◆ addFailedTest()

void XmlOutputter::addFailedTest ( Test test,
TestFailure failure,
int  testNumber,
XmlElement testsNode 
)
virtual

Adds a failed test to the failed tests node. Creates a new element containing datas about the failed test, and adds it to the failed tests element. Then, for all hooks, call failTestAdded().

◆ addFailedTests()

void XmlOutputter::addFailedTests ( FailedTests failedTests,
XmlElement rootNode 
)
virtual

◆ addFailureLocation()

void XmlOutputter::addFailureLocation ( TestFailure failure,
XmlElement testElement 
)
virtual

◆ addHook()

void XmlOutputter::addHook ( XmlOutputterHook hook)
virtual

Adds the specified hook to the outputter.

Parameters
hookHook to add. Must not be NULL.

◆ addStatistics()

void XmlOutputter::addStatistics ( XmlElement rootNode)
virtual

Adds the statics element to the root node.

Creates a new element containing statistics data and adds it to the root element. Then, for all hooks, call statisticsAdded().

Parameters
rootNodeRoot element.

◆ addSuccessfulTest()

void XmlOutputter::addSuccessfulTest ( Test test,
int  testNumber,
XmlElement testsNode 
)
virtual

Adds a successful test to the successful tests node. Creates a new element containing datas about the successful test, and adds it to the successful tests element. Then, for all hooks, call successfulTestAdded().

◆ addSuccessfulTests()

void XmlOutputter::addSuccessfulTests ( FailedTests failedTests,
XmlElement rootNode 
)
virtual

◆ fillFailedTestsMap()

void XmlOutputter::fillFailedTestsMap ( FailedTests failedTests)
protectedvirtual

◆ operator=()

void XmlOutputter::operator= ( const XmlOutputter copy)
private

Prevents the use of the copy operator.

◆ removeHook()

void XmlOutputter::removeHook ( XmlOutputterHook hook)
virtual

Removes the specified hook from the outputter.

Parameters
hookHook to remove.

◆ setRootNode()

void XmlOutputter::setRootNode ( )
virtual

Sets the root element and adds its children.

Set the root element of the XML Document and add its child elements.

For all hooks, call beginDocument() just after creating the root element (it is empty at this time), and endDocument() once all the datas have been added to the root element.

◆ setStandalone()

void XmlOutputter::setStandalone ( bool  standalone)
virtual

set the output document as standalone or not.

For the output document, specify wether it's a standalone XML document, or not.

Parameters
standaloneif true, the output will be specified as standalone. if false, it will be not.

◆ setStyleSheet()

void XmlOutputter::setStyleSheet ( const std::string &  styleSheet)
virtual

Sets the XSL style sheet used.

Parameters
styleSheetName of the style sheet used. If empty, then no style sheet is used (default).

◆ write()

void XmlOutputter::write ( )
virtual

Writes the specified result as an XML document to the stream.

Refer to examples/cppunittest/XmlOutputterTest.cpp for example of use and XML document structure.

Implements Outputter.

Member Data Documentation

◆ m_encoding

std::string XmlOutputter::m_encoding
protected

◆ m_hooks

Hooks XmlOutputter::m_hooks
protected

◆ m_result

TestResultCollector* XmlOutputter::m_result
protected

◆ m_stream

OStream& XmlOutputter::m_stream
protected

◆ m_styleSheet

std::string XmlOutputter::m_styleSheet
protected

◆ m_xml

XmlDocument* XmlOutputter::m_xml
protected

The documentation for this class was generated from the following files:

Send comments to:
CppUnit Developers