CppUnit project page FAQ CppUnit home page

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

XmlOutputter.h

Go to the documentation of this file.
00001 #ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H
00002 #define CPPUNIT_XMLTESTRESULTOUTPUTTER_H
00003 
00004 #include <cppunit/Portability.h>
00005 
00006 #if CPPUNIT_NEED_DLL_DECL
00007 #pragma warning( push )
00008 #pragma warning( disable: 4251 )  // X needs to have dll-interface to be used by clients of class Z
00009 #endif
00010 
00011 #include <cppunit/Outputter.h>
00012 #include <deque>
00013 #include <iostream>
00014 #include <map>
00015 #include <string>
00016 #include <utility>
00017 
00018 
00019 namespace CppUnit
00020 {
00021 
00022 class Test;
00023 class TestFailure;
00024 class TestResultCollector;
00025 
00026 
00030 class CPPUNIT_API XmlOutputter : public Outputter
00031 {
00032 public:
00038   XmlOutputter( TestResultCollector *result,
00039                 std::ostream &stream,
00040                 std::string encoding = "ISO-8859-1" );
00041 
00043   virtual ~XmlOutputter();
00044 
00050   virtual void write();
00051 
00056   class CPPUNIT_API Node
00057   {
00058   public:
00059     Node( std::string elementName,
00060           std::string content ="" );
00061     Node( std::string elementName,
00062           int numericContent );
00063     virtual ~Node();
00064 
00065     void addAttribute( std::string attributeName,
00066                        std::string value );
00067     void addAttribute( std::string attributeName,
00068                        int numericValue );
00069     void addNode( Node *node );
00070 
00071     std::string toString() const;
00072 
00073   private:
00074     typedef std::pair<std::string,std::string> Attribute;
00075 
00076     std::string attributesAsString() const;
00077     std::string escape( std::string value ) const;
00078     static std::string asString( int value );
00079 
00080   private:
00081     std::string m_name;
00082     std::string m_content;
00083     typedef std::deque<Attribute> Attributes;
00084     Attributes m_attributes;
00085     typedef std::deque<Node *> Nodes;
00086     Nodes m_nodes;
00087   };
00088 
00089 
00090   virtual void writeProlog();
00091   virtual void writeTestsResult();
00092 
00093   typedef std::map<Test *,TestFailure*> FailedTests;
00094   virtual Node *makeRootNode();
00095   virtual void addFailedTests( FailedTests &failedTests,
00096                                Node *rootNode );
00097   virtual void addSucessfulTests( FailedTests &failedTests,
00098                                   Node *rootNode );
00099   virtual void addStatistics( Node *rootNode );
00100   virtual void addFailedTest( Test *test,
00101                               TestFailure *failure,
00102                               int testNumber,
00103                               Node *testsNode );
00104   virtual void addFailureLocation( TestFailure *failure,
00105                                    Node *testNode );
00106   virtual void addSucessfulTest( Test *test, 
00107                                  int testNumber,
00108                                  Node *testsNode );
00109 protected:
00110   virtual void fillFailedTestsMap( FailedTests &failedTests );
00111 
00112 protected:
00113   TestResultCollector *m_result;
00114   std::ostream &m_stream;
00115   std::string m_encoding;
00116 
00117 private:
00119   XmlOutputter( const XmlOutputter &copy );
00120 
00122   void operator =( const XmlOutputter &copy );
00123 
00124 private:
00125 };
00126 
00127 
00128 
00129 }  // namespace CppUnit
00130 
00131 
00132 #if CPPUNIT_NEED_DLL_DECL
00133 #pragma warning( pop )
00134 #endif
00135 
00136 #endif  // CPPUNIT_XMLTESTRESULTOUTPUTTER_H

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers