1 // ////////////////////////////////////////////////////////////////////////// 2 // Implementation file ExceptionTestCaseDecoratorTest.cpp for class ExceptionTestCaseDecoratorTest 3 // (c)Copyright 2000, Baptiste Lepilleur. 4 // Created: 2002/08/03 5 // ////////////////////////////////////////////////////////////////////////// 6 7 #include "ExtensionSuite.h" 8 #include "ExceptionTestCaseDecoratorTest.h" 9 10 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ExceptionTestCaseDecoratorTest, 11 extensionSuiteName() ); 12 13 ExceptionTestCaseDecoratorTest()14ExceptionTestCaseDecoratorTest::ExceptionTestCaseDecoratorTest() 15 { 16 } 17 18 ~ExceptionTestCaseDecoratorTest()19ExceptionTestCaseDecoratorTest::~ExceptionTestCaseDecoratorTest() 20 { 21 } 22 23 24 void setUp()25ExceptionTestCaseDecoratorTest::setUp() 26 { 27 m_testListener = new MockTestListener( "mock-testlistener" ); 28 m_result = new CPPUNIT_NS::TestResult(); 29 m_result->addListener( m_testListener ); 30 31 m_test = new MockTestCase( "mock-decorated-testcase" ); 32 m_decorator = new FailureExceptionTestCase( m_test ); 33 } 34 35 36 void tearDown()37ExceptionTestCaseDecoratorTest::tearDown() 38 { 39 delete m_decorator; 40 delete m_result; 41 delete m_testListener; 42 } 43 44 45 void testNoExceptionThrownFailed()46ExceptionTestCaseDecoratorTest::testNoExceptionThrownFailed() 47 { 48 m_testListener->setExpectedAddFailureCall(1); 49 m_test->setExpectedSetUpCall(); 50 m_test->setExpectedRunTestCall(); 51 m_test->setExpectedTearDownCall(); 52 53 m_decorator->run( m_result ); 54 55 m_testListener->verify(); 56 } 57 58 59 void testExceptionThrownPass()60ExceptionTestCaseDecoratorTest::testExceptionThrownPass() 61 { 62 m_testListener->setExpectNoFailure(); 63 m_test->setExpectedSetUpCall(); 64 m_test->setExpectedRunTestCall(); 65 m_test->setExpectedTearDownCall(); 66 m_test->makeRunTestThrow(); 67 68 m_decorator->run( m_result ); 69 70 m_testListener->verify(); 71 } 72