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 /src/cppunit/TestCase.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 'src/cppunit/TestCase.cpp')
| -rw-r--r-- | src/cppunit/TestCase.cpp | 120 |
1 files changed, 68 insertions, 52 deletions
diff --git a/src/cppunit/TestCase.cpp b/src/cppunit/TestCase.cpp index 9499416..8f5494a 100644 --- a/src/cppunit/TestCase.cpp +++ b/src/cppunit/TestCase.cpp @@ -10,124 +10,140 @@ namespace CppUnit { /// Create a default TestResult -CppUnit::TestResult* TestCase::defaultResult () -{ return new TestResult; } +CppUnit::TestResult* +TestCase::defaultResult() +{ + return new TestResult; +} /// Run the test and catch any exceptions that are triggered by it void -TestCase::run (TestResult *result) +TestCase::run( TestResult *result ) { - result->startTest (this); + result->startTest(this); - try { - setUp (); - - try { - runTest (); - } - catch (Exception& e) { + try { + setUp(); + + try { + runTest(); + } + catch ( Exception &e ) { Exception *copy = e.clone(); - result->addFailure (this, copy); - } - catch (std::exception& e) { - result->addError (this, new Exception (e.what ())); - } - catch (...) { - Exception *e = new Exception ("caught unknown exception"); - result->addError (this, e); - } - - try { - tearDown (); - } - catch ( ... ) { + result->addFailure( this, copy ); + } + catch ( std::exception &e ) { + result->addError( this, new Exception( e.what() ) ); + } + catch (...) { + Exception *e = new Exception( "caught unknown exception" ); + result->addError( this, e ); + } + + try { + tearDown(); + } + catch (...) { result->addError( this, new Exception( "tearDown() failed" ) ); - } - } - catch ( ... ) { - result->addError( this, new Exception( "setUp() failed" ) ); - } - - result->endTest (this); + } + } + catch (...) { + result->addError( this, new Exception( "setUp() failed" ) ); + } + + result->endTest( this ); } /// A default run method -TestResult *TestCase::run () +TestResult * +TestCase::run() { - TestResult *result = defaultResult (); + TestResult *result = defaultResult(); run (result); return result; - } + /// All the work for runTest is deferred to subclasses -void TestCase::runTest () +void +TestCase::runTest() { } + /** Constructs a test case. * \param name the name of the TestCase. **/ -TestCase::TestCase (std::string name) - : m_name (name) +TestCase::TestCase( std::string name ) + : m_name(name) { } + /** Constructs a test case for a suite. * This TestCase is intended for use by the TestCaller and should not * be used by a test case for which run() is called. **/ -TestCase::TestCase () - : m_name ("") +TestCase::TestCase() + : m_name( "" ) { } /// Destructs a test case -TestCase::~TestCase () -{} +TestCase::~TestCase() +{ +} /// Returns a count of all the tests executed -int TestCase::countTestCases () const -{ return 1; } +int +TestCase::countTestCases() const +{ + return 1; +} /// Returns the name of the test case std::string - TestCase::getName () const +TestCase::getName() const { return m_name; } /// A hook for fixture set up -void TestCase::setUp () -{} +void +TestCase::setUp() +{ +} /// A hook for fixture tear down -void TestCase::tearDown () -{} +void +TestCase::tearDown() +{ +} /// Returns the name of the test case instance std::string - TestCase::toString () const +TestCase::toString() const { std::string className; #if CPPUNIT_USE_TYPEINFO_NAME - const std::type_info& thisClass = typeid (*this); + const std::type_info& thisClass = typeid( *this ); className = thisClass.name(); #else className = "TestCase"; #endif - return className + "." + getName (); + return className + "." + getName(); } + } // namespace CppUnit |
