Menu

[r223]: / trunk / cppunit / include / cppunit / XmlOutputter.h  Maximize  Restore  History

Download this file

136 lines (106 with data), 3.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H
#define CPPUNIT_XMLTESTRESULTOUTPUTTER_H
#include <cppunit/Portability.h>
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( push )
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
#endif
#include <cppunit/Outputter.h>
#include <deque>
#include <iostream>
#include <map>
#include <string>
#include <utility>
namespace CppUnit
{
class Test;
class TestFailure;
class TestResultCollector;
/*! Outputs a TestResultCollector in XML format.
*/
class CPPUNIT_API XmlOutputter : public Outputter
{
public:
/*! Constructs a XmlOutputter object.
*/
XmlOutputter( TestResultCollector *result,
std::ostream &stream,
std::string encoding = "ISO-8859-1" );
/// Destructor.
virtual ~XmlOutputter();
/*! Write the specified result as an XML document in the specified stream.
*
* Refer to examples/cppunittest/XmlOutputterTest.cpp for example
* of use and XML document structure.
*
* \param result TestResult to write.
* \param stream Output stream the result are wrote into.
*/
virtual void write();
/*! This class represents an XML Element.
* \warning This class will probably be replaced with an abstract
* builder in future version.
*/
class CPPUNIT_API Node
{
public:
Node( std::string elementName,
std::string content ="" );
Node( std::string elementName,
int numericContent );
virtual ~Node();
void addAttribute( std::string attributeName,
std::string value );
void addAttribute( std::string attributeName,
int numericValue );
void addNode( Node *node );
std::string toString() const;
private:
typedef std::pair<std::string,std::string> Attribute;
std::string attributesAsString() const;
std::string escape( std::string value ) const;
static std::string asString( int value );
private:
std::string m_name;
std::string m_content;
typedef std::deque<Attribute> Attributes;
Attributes m_attributes;
typedef std::deque<Node *> Nodes;
Nodes m_nodes;
};
virtual void writeProlog();
virtual void writeTestsResult();
typedef std::map<Test *,TestFailure*> FailedTests;
virtual Node *makeRootNode();
virtual void addFailedTests( FailedTests &failedTests,
Node *rootNode );
virtual void addSucessfulTests( FailedTests &failedTests,
Node *rootNode );
virtual void addStatistics( Node *rootNode );
virtual void addFailedTest( Test *test,
TestFailure *failure,
int testNumber,
Node *testsNode );
virtual void addFailureLocation( TestFailure *failure,
Node *testNode );
virtual void addSucessfulTest( Test *test,
int testNumber,
Node *testsNode );
protected:
virtual void fillFailedTestsMap( FailedTests &failedTests );
protected:
TestResultCollector *m_result;
std::ostream &m_stream;
std::string m_encoding;
private:
/// Prevents the use of the copy constructor.
XmlOutputter( const XmlOutputter &copy );
/// Prevents the use of the copy operator.
void operator =( const XmlOutputter &copy );
private:
};
} // namespace CppUnit
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( pop )
#endif
#endif // CPPUNIT_XMLTESTRESULTOUTPUTTER_H
MongoDB Logo MongoDB