diff options
author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-02-28 09:58:40 +0000 |
---|---|---|
committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-02-28 09:58:40 +0000 |
commit | 2c7af6bda8b090a31dd39e3ca6e5c55ed7758fb9 (patch) | |
tree | bab900654046a7afabcf534647be53ea1d4a90a3 /examples/cppunittest/TestCallerTest.cpp | |
parent | 36905b4f9faf4075abfa1c695c443185650c47a2 (diff) | |
download | cppunit-2c7af6bda8b090a31dd39e3ca6e5c55ed7758fb9.tar.gz |
NEW: updated and restructured.
NEW: updated and restructured.
* include/cppunit/CompilerOutputter.h:
* src/cppunit/CompilerOutputter.cpp:
updated against TestResultChange. Changed TestResult to TestResultCollector.
* include/cppunit/extensions/HelperMacros.h: minor documentation fix.
* include/cppunit/Outputter.h: added. Abstract base class for all Outputter.
* include/cppunit/Portability.h: made the fix on OStringStream suggested by
Bob Summerwill to remove level 4 warning with VC++.
* include/cppunit/TestAssert.h: added macro CPPUNIT_ASSERT_EQUAL_MESSAGE.
* src/cppunit/TestFailure.cpp:
* include/cppunit/TestFailure.h: added method clone() to duplicate a failure. Made
all method virtual.
* include/cppunit/TestListener.h: changed signature of addFailure() to
addFailure( const TestFailure &failure ). Failure is now only a temporary object.
* include/cppunit/Outputter.h: added. Abstract base class for all outputter. Used
by TextTestRunner.
* include/cppunit/SynchronizedObject.h:
* src/cppunit/SynchronizedObject.cpp: added. Class extracted from TestResult.
Base class for objects that can be accessed from different threads.
* include/cppunit/TestResult.h: TestFailure.h is no longer included.
* include/cppunit/TestResult.h:
* src/cppunit/TestResult.cpp: extracted all methods related to keeping track
of the result to the new TestResultCollector class which is a TestListener.
* include/cppunit/TestResultCollector.h:
* src/cppunit/TestResultCollector.cpp: added. TestListener which kept track
of the result of the test run. All failure/error, and tests are tracked.
* include/cppunit/TestSucessListener.h:
* src/cppunit/TestSucessListener.cpp: added. TestListener extracted from
TestResult. Is responsible for wasSucessful().
* include/cppunit/TestCase.h:
* src/cppunit/TestCase.cpp: reindented.
* include/cppunit/TextOutputter.h:
* src/cppunit/TextOutputter.cpp: added. Copied from the deprecated
TextTestResult and modified to act as an Ouputter.
* include/cppunit/TextTestProgressListener.h:
* src/cppunit/TextTestProgressListener.cpp: Copied from the deprecated
TextTestResult and modified to print the dot while the test are running.
* include/cppunit/TextTestResult.h:
* src/cppunit/TextTestResult.cpp: updated against TestResult change.
No compatiblity break. Deprecated.
* include/cppunit/TextTestRunner.h:
* src/cppunit/TextTestRunner.cpp: updated to work with the new TestResult.
Use TextTestProgressListener and TextOutputter instead of TextTestResult.
Any outputter with interface Outputter can be used to print the test result
(CompilerOutputter, XmlOutputter, TextOutputter...)
* include/cppunit/XmlOutputter.h:
* src/cppunit/XmlOutputter.cpp: updated against TestResultChange.
Changed TestResult to TestResultCollector.
* src/msvc6/TestRunnerDlg.h:
* src/msvc6/TestRunnerDlg.cpp: fixed the 'fullrowselect' feature of the list view.
The dialog is a TestListener itself, it no longer use the GUITestResult class.
* src/msvc6/TestRunner.rc: moved the "autorun test button" in such a way that it
did not overlap the progress bar anymore.
* src/msvc6/MfcSynchronizationObject.h: added. Generic SynchronizedObject
lock for MFC.
* src/msvc6/GUITestResult.h :
* src/msvc6/GUITestResult.cpp : removed.
* src/qttestrunner/TestRunnerModel.h:
* src/qttestrunner/TestRunnerModel.cpp: changed addFailure() signature to reflect
change on TestListener.
* examples/cppunittest/CppUnitTestMain.cpp: updated to use the new Outputter
abstraction and TextTestRunner facilities.
* examples/cppunittest/FailingTestCase.h:
* examples/cppunittest/FailingTestCase.cpp: removed. Replaced by MockTestCase.
* examples/cppunittest/FailingTestCase.h:
* examples/cppunittest/FailingTestCase.h:
* examples/cppunittest/HelperMacrosTest.h:
* examples/cppunittest/HelperMacrosTest.cpp: Updated against TestResult change.
Use MockTestListener instead of TestResult to check for sucess or failure.
* examples/cppunittest/MockTestListener.h:
* examples/cppunittest/MockTestListener.cpp: the class now behave like a mock
object.
* examples/cppunittest/MockTestCase.h:
* examples/cppunittest/MockTestCase.cpp: added. Mock TestCase object.
* examples/cppunittest/OrthodoxTest.h:
* examples/cppunittest/OrthodoxTest.cpp: Updated against TestResult change.
Use MockTestListener instead of TestResult to check for sucess or failure.
* examples/cppunittest/SynchronizedTestResult.h: Updated against TestResult
change.
* examples/cppunittest/TestCallerTest.h:
* examples/cppunittest/TestCallerTest.cpp: Updated against TestResult change.
Use MockTestListener instead of TestResult.
* examples/cppunittest/TestCaseTest.h:
* examples/cppunittest/TestCaseTest.cpp: Updated against TestResult change.
Use MockTestListener and MockTestCase instead of FailingTestCase and TestResult.
* examples/cppunittest/TestDecoratorTest.h:
* examples/cppunittest/TestDecoratorTest.cpp: Updated against TestResult change.
Use MockTestCase instead of FailingTestCase.
* examples/cppunittest/TestListenerTest.h:
* examples/cppunittest/TestListenerTest.cpp: removed. Those unit tests have been
rewrote and moved to TestResultTest.
* examples/cppunittest/TestResultTest.h:
* examples/cppunittest/TestResultTest.cpp: Updated to test the new interface.
Tests from TestListenerTest have been moved here.
* examples/cppunittest/TestResultCollectorTest.h:
* examples/cppunittest/TestResultCollectorTest.cpp: added. Tests for the class
that been extracted from TestResult.
* examples/cppunittest/TestSetUpTest.h:
* examples/cppunittest/TestSetUpTest.cpp: renamed SetUp inner class to MockSetUp.
Changed interface to be more akin to a Mock object.
* examples/cppunittest/TestSuiteTest.h:
* examples/cppunittest/TestSuiteTest.cpp: Updated against TestResult change,
and rewrote to use MockTestCase instead of FailingTestCase.
* examples/cppunittest/XmlOutputterTest.h:
* examples/cppunittest/XmlOutputterTest.cpp: Updated against TestResult change.
Added some utility methods to make the update easier.
Diffstat (limited to 'examples/cppunittest/TestCallerTest.cpp')
-rw-r--r-- | examples/cppunittest/TestCallerTest.cpp | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/examples/cppunittest/TestCallerTest.cpp b/examples/cppunittest/TestCallerTest.cpp index 5584696..e5e5db9 100644 --- a/examples/cppunittest/TestCallerTest.cpp +++ b/examples/cppunittest/TestCallerTest.cpp @@ -41,22 +41,6 @@ TestCallerTest::~TestCallerTest() } -CppUnit::TestSuite * -TestCallerTest::suite() -{ - CppUnit::TestSuiteBuilder<TestCallerTest> suite("TestCallerTest"); - - suite.addTestCaller( "testBasicConstructor", &TestCallerTest::testBasicConstructor ); - suite.addTestCaller( "testReferenceConstructor", &TestCallerTest::testReferenceConstructor ); - suite.addTestCaller( "testPointerConstructor", &TestCallerTest::testPointerConstructor ); - suite.addTestCaller( "testExpectFailureException", &TestCallerTest::testExpectFailureException ); - suite.addTestCaller( "testExpectException", &TestCallerTest::testExpectException ); - suite.addTestCaller( "testExpectedExceptionNotCaught", &TestCallerTest::testExpectedExceptionNotCaught ); - - return suite.takeSuite(); -} - - void TestCallerTest::setUp() { @@ -66,7 +50,9 @@ TestCallerTest::setUp() m_tearDownCount = 0; m_testCount = 0; TrackedTestCase::setTracker( this ); + m_testListener = new MockTestListener( "listener1" ); m_result = new CppUnit::TestResult(); + m_result->addListener( m_testListener ); } @@ -75,6 +61,7 @@ TestCallerTest::tearDown() { TrackedTestCase::removeTracker(); delete m_result; + delete m_testListener; } @@ -174,8 +161,9 @@ TestCallerTest::testExpectFailureException() CppUnit::TestCaller<ExceptionThrower,FailureException> caller( m_testName, &ExceptionThrower::testThrowFailureException ); + m_testListener->setExpectNoFailure(); caller.run( m_result ); - CPPUNIT_ASSERT( m_result->wasSuccessful() ); + m_testListener->verify(); } @@ -185,8 +173,9 @@ TestCallerTest::testExpectException() CppUnit::TestCaller<ExceptionThrower,CppUnit::Exception> caller( m_testName, &ExceptionThrower::testThrowException ); + m_testListener->setExpectNoFailure(); caller.run( m_result ); - CPPUNIT_ASSERT( m_result->wasSuccessful() ); + m_testListener->verify(); } @@ -196,14 +185,9 @@ TestCallerTest::testExpectedExceptionNotCaught() CppUnit::TestCaller<ExceptionThrower,FailureException> caller( m_testName, &ExceptionThrower::testThrowNothing ); + m_testListener->setExpectedAddFailureCall( 1 ); caller.run( m_result ); - CPPUNIT_ASSERT( !m_result->wasSuccessful() ); - CPPUNIT_ASSERT_EQUAL( 1, int(m_result->failures().size()) ); -// Can differentiate throw 'new Exception' from throw 'Exception' -// only by text message which is unsafe. -// Possible solution: subclass Exception: -// CppUnit::Exception *e = m_result->failues()[0]->thrownException(); -// CPPUNIT_ASSERT( e->isInstanceOf( FailureException::type() ) ); + m_testListener->verify(); } |