[Cppunit-devel] CppUnit - TestCase.cpp code addition
Brought to you by:
blep
From: Matt P. <mpa...@op...> - 2001-11-12 06:24:01
|
Hi Guys, Additions we would like to see included in the file 'TestCase.cpp' from the CppUnit test suite are shown in red below. The additions provide for further feedback when failures occur in the setUp() and tearDown() routines. Currently failures in these routines report that the routine itself has failed. Please use your discretion as to whether the additions should be calls to 'addFailure()' or 'addError()' as necessary. Thanks. Matt Parkinson R&D Software Engineer Opcom PO Box 149 Toowong QLD 4066 AUSTRALIA Office +61 07 3371 1311 Fax +61 07 3371 1257 Email mpa...@op... Web www.opcom.com.au /// Run the test and catch any exceptions that are triggered by it void TestCase::run (TestResult *result) { result->startTest (this); 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 (Exception& e) { Exception *copy = e.clone(); result->addFailure (this, copy); } catch ( ... ) { result->addError( this, new Exception( "tearDown() failed" ) ); } } catch (Exception& e) { Exception *copy = e.clone(); result->addFailure (this, copy); } catch ( ... ) { result->addError( this, new Exception( "setUp() failed" ) ); } result->endTest (this); } |