1 #ifndef MOCKTESTCASE_H 2 #define MOCKTESTCASE_H 3 4 #include <cppunit/TestCase.h> 5 6 7 /*! \class MockTestCase 8 * \brief This class represents a mock test case. 9 */ 10 class MockTestCase : public CPPUNIT_NS::TestCase 11 { 12 public: 13 typedef CPPUNIT_NS::TestCase SuperClass; // work around VC++ call to super class method. 14 15 /*! Constructs a MockTestCase object. 16 */ 17 MockTestCase( std::string name ); 18 19 /// Destructor. 20 virtual ~MockTestCase(); 21 22 void setExpectedSetUpCall( int callCount = 1 ); 23 void setExpectedTearDownCall( int callCount = 1 ); 24 void setExpectedRunTestCall( int callCount = 1 ); 25 void setExpectedCountTestCasesCall( int callCount = 1 ); 26 27 void makeSetUpThrow(); 28 void makeTearDownThrow(); 29 void makeRunTestThrow(); 30 void makeFindTestPathPassFor( const CPPUNIT_NS::Test *testFound ); 31 32 void verify(); 33 34 protected: 35 int countTestCases() const; 36 void setUp(); 37 void tearDown(); 38 void runTest(); 39 // bool findTestPath( const CPPUNIT_NS::Test *test, 40 // CPPUNIT_NS::TestPath &testPath ); 41 42 private: 43 /// Prevents the use of the copy constructor. 44 MockTestCase( const MockTestCase © ); 45 46 /// Prevents the use of the copy operator. 47 void operator =( const MockTestCase © ); 48 49 private: 50 bool m_hasSetUpExpectation; 51 int m_expectedSetUpCall; 52 int m_actualSetUpCall; 53 54 bool m_hasTearDownExpectation; 55 int m_expectedTearDownCall; 56 int m_actualTearDownCall; 57 58 bool m_expectRunTestCall; 59 int m_expectedRunTestCallCount; 60 int m_actualRunTestCallCount; 61 bool m_expectCountTestCasesCall; 62 int m_expectedCountTestCasesCallCount; 63 int m_actualCountTestCasesCallCount; 64 65 bool m_setUpThrow; 66 bool m_tearDownThrow; 67 bool m_runTestThrow; 68 const CPPUNIT_NS::Test *m_passingTest; 69 }; 70 71 72 73 74 75 #endif // MOCKTESTCASE_H 76