summaryrefslogtreecommitdiff
path: root/examples/cppunittest/XmlOutputterTest.h
blob: 697a452cca1c2e02f4ff2897838baa97800a2727 (plain)
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
#ifndef CPPUNITEST_XMLTESTRESULTOUTPUTTERTEST_H
#define CPPUNITEST_XMLTESTRESULTOUTPUTTERTEST_H

#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/portability/CppUnitDeque.h>
#include <cppunit/Test.h>
#include <cppunit/TestFailure.h>
#include <cppunit/TestResultCollector.h>


/*! \class XmlOutputterTest
 * \brief Unit tests for XmlOutputter.
 */
class XmlOutputterTest : public CPPUNIT_NS::TestFixture
{
  CPPUNIT_TEST_SUITE( XmlOutputterTest );
  CPPUNIT_TEST( testWriteXmlResultWithNoTest );
  CPPUNIT_TEST( testWriteXmlResultWithOneFailure );
  CPPUNIT_TEST( testWriteXmlResultWithOneError );
  CPPUNIT_TEST( testWriteXmlResultWithOneSuccess );
  CPPUNIT_TEST( testWriteXmlResultWithThreeFailureTwoErrorsAndTwoSuccess );
  CPPUNIT_TEST( testHook );
  CPPUNIT_TEST_SUITE_END();

public:
  /*! Constructs a XmlOutputterTest object.
   */
  XmlOutputterTest();

  /// Destructor.
  virtual ~XmlOutputterTest();

  void setUp();
  void tearDown();
  void testWriteXmlResultWithNoTest();
  void testWriteXmlResultWithOneFailure();
  void testWriteXmlResultWithOneError();
  void testWriteXmlResultWithOneSuccess();
  void testWriteXmlResultWithThreeFailureTwoErrorsAndTwoSuccess();

  void testHook();

private:
  class MockHook;

  /// Prevents the use of the copy constructor.
  XmlOutputterTest( const XmlOutputterTest &copy );

  /// Prevents the use of the copy operator.
  void operator =( const XmlOutputterTest &copy );

  std::string statistics( int tests, 
                          int total, 
                          int error, 
                          int failure );

  void addTest( std::string testName );
  void addTestFailure( std::string testName,
                       std::string message,
                       CPPUNIT_NS::SourceLine sourceLine = CPPUNIT_NS::SourceLine() );
  void addTestError( std::string testName,
                     std::string message,
                     CPPUNIT_NS::SourceLine sourceLine = CPPUNIT_NS::SourceLine() );
  void addGenericTestFailure( std::string testName,
                              CPPUNIT_NS::Message message,
                              CPPUNIT_NS::SourceLine sourceLine,
                              bool isError );

  CPPUNIT_NS::Test *makeDummyTest( std::string testName );

private:
  CPPUNIT_NS::TestResultCollector *m_result;
  CppUnitDeque<CPPUNIT_NS::Test *> m_dummyTests;
};



#endif  // CPPUNITEST_XMLTESTRESULTOUTPUTTERTEST_H