CppUnit - The Unit Testing Library

CppUnit project page | FAQ

XmlOutputter.h
Go to the documentation of this file.
1#ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H
2#define CPPUNIT_XMLTESTRESULTOUTPUTTER_H
3
4#include <cppunit/Portability.h>
5
6#if CPPUNIT_NEED_DLL_DECL
7#pragma warning( push )
8#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
9#endif
10
11#include <cppunit/Outputter.h>
12#include <deque>
13#include <map>
14#include <cppunit/portability/Stream.h>
15
16
17 CPPUNIT_NS_BEGIN
18
19
20class Test;
21class TestFailure;
22class TestResultCollector;
23class XmlDocument;
24class XmlElement;
25class XmlOutputterHook;
26
27
39 class CPPUNIT_API XmlOutputter : public Outputter
40{
41public:
47 XmlOutputter( TestResultCollector *result,
48 OStream &stream,
49 const std::string& encoding = std::string("ISO-8859-1") );
50
52 virtual ~XmlOutputter();
53
57 virtual void addHook( XmlOutputterHook *hook );
58
62 virtual void removeHook( XmlOutputterHook *hook );
63
69 virtual void write();
70
76 virtual void setStyleSheet( const std::string &styleSheet );
77
86 virtual void setStandalone( bool standalone );
87
88 typedef std::map<Test *,TestFailure*, std::less<Test*> > FailedTests;
89
98 virtual void setRootNode();
99
100 virtual void addFailedTests( FailedTests &failedTests,
101 XmlElement *rootNode );
102
103 virtual void addSuccessfulTests( FailedTests &failedTests,
104 XmlElement *rootNode );
105
112 virtual void addStatistics( XmlElement *rootNode );
113
119 virtual void addFailedTest( Test *test,
120 TestFailure *failure,
121 int testNumber,
122 XmlElement *testsNode );
123
124 virtual void addFailureLocation( TestFailure *failure,
125 XmlElement *testElement );
126
127
133 virtual void addSuccessfulTest( Test *test,
134 int testNumber,
135 XmlElement *testsNode );
136protected:
137 virtual void fillFailedTestsMap( FailedTests &failedTests );
138
139protected:
140 typedef std::deque<XmlOutputterHook *> Hooks;
141
142 TestResultCollector *m_result;
143 OStream &m_stream;
144 std::string m_encoding;
145 std::string m_styleSheet;
146 XmlDocument *m_xml;
147 Hooks m_hooks;
148
149private:
151 XmlOutputter( const XmlOutputter &copy );
152
154 void operator =( const XmlOutputter &copy );
155
156private:
157};
158
159
160 CPPUNIT_NS_END
161
162#if CPPUNIT_NEED_DLL_DECL
163#pragma warning( pop )
164#endif
165
166
167#endif // CPPUNIT_XMLTESTRESULTOUTPUTTER_H
CPPUNIT_API
#define CPPUNIT_API
Definition CppUnitApi.h:27
Outputter.h
Portability.h
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition Portability.h:105
Stream.h
OStream
CPPUNIT_NS_BEGIN typedef std::ostream OStream
Definition Stream.h:330
Outputter
Abstract outputter to print test result summary.
Definition Outputter.h:14
Outputter::write
virtual void write()=0
TestFailure
Record of a failed Test execution.
Definition TestFailure.h:25
Test
Base class for all test objects.
Definition Test.h:26
TestResultCollector
Collects test result.
Definition TestResultCollector.h:32
XmlDocument
A XML Document.
Definition XmlDocument.h:28
XmlElement
A XML Element.
Definition XmlElement.h:34
XmlOutputterHook
Hook to customize Xml output.
Definition XmlOutputterHook.h:118
XmlOutputter::addHook
virtual void addHook(XmlOutputterHook *hook)
Adds the specified hook to the outputter.
Definition XmlOutputter.cpp:36
XmlOutputter::setStandalone
virtual void setStandalone(bool standalone)
set the output document as standalone or not.
Definition XmlOutputter.cpp:65
XmlOutputter::m_encoding
std::string m_encoding
Definition XmlOutputter.h:144
XmlOutputter::FailedTests
std::map< Test *, TestFailure *, std::less< Test * > > FailedTests
Definition XmlOutputter.h:88
XmlOutputter::addFailedTests
virtual void addFailedTests(FailedTests &failedTests, XmlElement *rootNode)
Definition XmlOutputter.cpp:106
XmlOutputter::removeHook
virtual void removeHook(XmlOutputterHook *hook)
Removes the specified hook from the outputter.
Definition XmlOutputter.cpp:43
XmlOutputter::addStatistics
virtual void addStatistics(XmlElement *rootNode)
Adds the statics element to the root node.
Definition XmlOutputter.cpp:140
XmlOutputter::addFailedTest
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 ...
Definition XmlOutputter.cpp:156
XmlOutputter::m_hooks
Hooks m_hooks
Definition XmlOutputter.h:147
XmlOutputter::XmlOutputter
XmlOutputter(const XmlOutputter &copy)
Prevents the use of the copy constructor.
XmlOutputter::m_stream
OStream & m_stream
Definition XmlOutputter.h:143
XmlOutputter::m_xml
XmlDocument * m_xml
Definition XmlOutputter.h:146
XmlOutputter::m_styleSheet
std::string m_styleSheet
Definition XmlOutputter.h:145
XmlOutputter::addSuccessfulTests
virtual void addSuccessfulTests(FailedTests &failedTests, XmlElement *rootNode)
Definition XmlOutputter.cpp:123
XmlOutputter::m_result
TestResultCollector * m_result
Definition XmlOutputter.h:142
XmlOutputter::addSuccessfulTest
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...
Definition XmlOutputter.cpp:194
XmlOutputter::XmlOutputter
XmlOutputter(TestResultCollector *result, OStream &stream, const std::string &encoding=std::string("ISO-8859-1"))
Constructs a XmlOutputter object.
Definition XmlOutputter.cpp:16
XmlOutputter::setRootNode
virtual void setRootNode()
Sets the root element and adds its children.
Definition XmlOutputter.cpp:72
XmlOutputter::addFailureLocation
virtual void addFailureLocation(TestFailure *failure, XmlElement *testElement)
Definition XmlOutputter.cpp:182
XmlOutputter::Hooks
std::deque< XmlOutputterHook * > Hooks
Definition XmlOutputter.h:140
XmlOutputter::fillFailedTestsMap
virtual void fillFailedTestsMap(FailedTests &failedTests)
Definition XmlOutputter.cpp:93
XmlOutputter::setStyleSheet
virtual void setStyleSheet(const std::string &styleSheet)
Sets the XSL style sheet used.
Definition XmlOutputter.cpp:58

| Send comments to: CppUnit Developers