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/TestCaseTest.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/TestCaseTest.cpp')
-rw-r--r-- | examples/cppunittest/TestCaseTest.cpp | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/examples/cppunittest/TestCaseTest.cpp b/examples/cppunittest/TestCaseTest.cpp index 81e0c4a..5479c0e 100644 --- a/examples/cppunittest/TestCaseTest.cpp +++ b/examples/cppunittest/TestCaseTest.cpp @@ -1,6 +1,7 @@ #include "CoreSuite.h" +#include "FailureException.h" +#include "MockTestCase.h" #include "TestCaseTest.h" -#include "FailingTestCase.h" #include <cppunit/TestResult.h> /* @@ -25,7 +26,9 @@ TestCaseTest::~TestCaseTest() void TestCaseTest::setUp() { + m_testListener = new MockTestListener( "mock-testlistener" ); m_result = new CppUnit::TestResult(); + m_result->addListener( m_testListener ); } @@ -33,6 +36,7 @@ void TestCaseTest::tearDown() { delete m_result; + delete m_testListener; } @@ -78,13 +82,24 @@ TestCaseTest::checkFailure( bool failSetUp, { try { - FailingTestCase test( failSetUp, failRunTest, failTearDown ); - test.run( m_result ); - test.verify( !failSetUp, !failSetUp ); + MockTestCase testCase( "mock-test" ); + if ( failSetUp ) + testCase.makeSetUpThrow(); + if ( failRunTest ) + testCase.makeRunTestThrow(); + if ( failTearDown ) + testCase.makeTearDownThrow(); + testCase.setExpectedSetUpCall( 1 ); + testCase.setExpectedRunTestCall( failSetUp ? 0 : 1 ); + testCase.setExpectedTearDownCall( failSetUp ? 0 : 1 ); + + testCase.run( m_result ); + + testCase.verify(); } catch ( FailureException & ) { - CPPUNIT_ASSERT_MESSAGE( "exception should have been catched", false ); + CPPUNIT_ASSERT_MESSAGE( "exception should have been caught", false ); } } @@ -117,34 +132,27 @@ TestCaseTest::testConstructorWithName() void TestCaseTest::testDefaultRun() { - CppUnit::TestCase test; - std::auto_ptr<CppUnit::TestResult> result( test.run() ); + MockTestCase test( "mocktest" ); + test.setExpectedSetUpCall(); + test.setExpectedRunTestCall(); + test.setExpectedTearDownCall(); - checkResult( 0, 0, 1, result.get() ); + std::auto_ptr<CppUnit::TestResult> result( test.run() ); + test.verify(); } void TestCaseTest::testTwoRun() { - FailingTestCase test1( false, true, false ); + MockTestCase test1( "mocktest1" ); + test1.makeRunTestThrow(); + m_testListener->setExpectedStartTestCall( 2 ); + m_testListener->setExpectedAddFailureCall( 2 ); + m_testListener->setExpectedEndTestCall( 2 ); + test1.run( m_result ); test1.run( m_result ); - - FailingTestCase test2( false, false, false ); - test2.run( m_result ); - checkResult( 2, 0, 1, m_result ); -} - - -void -TestCaseTest::checkResult( int failures, - int errors, - int testsRun, - CppUnit::TestResult *result ) -{ - CPPUNIT_ASSERT_EQUAL( testsRun, result->runTests() ); - CPPUNIT_ASSERT_EQUAL( errors, result->testErrors() ); - CPPUNIT_ASSERT_EQUAL( failures, result->testFailures() ); + m_testListener->verify(); } |