[Cppunit-devel] REQUEST: throw user-defined errors in setUp() and tearDown()
Brought to you by:
blep
|
From: John L. <jl...@iu...> - 2002-06-21 20:57:07
|
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 =3D e.clone();
result->addFailure( this, copy );
}
catch ( std::exception &e ) {
result->addError( this, new Exception( e.what() ) );
}
catch (...) {
Exception *e =3D 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 =3D e.clone();
result->addError( this, copy );
}
to the outer most try block so that I can get more meaningful output
when errors occur.=20
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
|