Re: [Cppunit-devel] REQUEST: throw user-defined errors in setUp() and tearDown()
Brought to you by:
blep
From: Baptiste L. <gai...@fr...> - 2002-07-10 18:48:18
|
It will be done. It goes along with the following TODO features: - Provide a mean for the user to catch 'custom' exception in TestCase::run (exception that do not subclass std::exception, such as MFC CException, or RogueWave RWXMsg). That feature will likely result in a piece of code that will run a specific method, catching exceptions and assertion failures. This should avoid that so very long method... Though, notes that you usually try to avoid putting assertion in setUp() and tearDown() (though the memory/resource leaks detection is a good candidate for a tearDown assertions). Baptiste. ----- Original Message ----- From: "John Lam" <jl...@iu...> To: <cpp...@li...> Sent: Friday, June 21, 2002 10:57 PM Subject: [Cppunit-devel] REQUEST: throw user-defined errors in setUp() and tearDown() If my setUp() or tearDown() methods fail, I would like to have something more specific than "setUp() failed ..." showing up in my logs. I'd like to propose the following change to TestCase.cpp: It currently reads: 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->addError( this, new Exception( "tearDown() failed" ) ); } } catch (...) { result->addError( this, new Exception( "setUp() failed" ) ); } I would like to add: catch ( const Exception &e ) { Exception *copy = e.clone(); result->addError( this, copy ); } to the outer most try block so that I can get more meaningful output when errors occur. Similarly, I would like to add the same code to the try block that guards the call to tearDown(). Does this sound reasonable to the community? Cheers, -John http://www.iunknown.com ------------------------------------------------------- Sponsored by: ThinkGeek at http://www.ThinkGeek.com/ _______________________________________________ Cppunit-devel mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppunit-devel |