Run the test and catch any exceptions that are triggered by it
| 50 | |
| 51 | /// Run the test and catch any exceptions that are triggered by it |
| 52 | void |
| 53 | TestCase::run( TestResult *result ) |
| 54 | { |
| 55 | result->startTest(this); |
| 56 | /* |
| 57 | try { |
| 58 | setUp(); |
| 59 | |
| 60 | try { |
| 61 | runTest(); |
| 62 | } |
| 63 | catch ( Exception &e ) { |
| 64 | Exception *copy = e.clone(); |
| 65 | result->addFailure( this, copy ); |
| 66 | } |
| 67 | catch ( std::exception &e ) { |
| 68 | result->addError( this, new Exception( Message( "uncaught std::exception", |
| 69 | e.what() ) ) ); |
| 70 | } |
| 71 | catch (...) { |
| 72 | Exception *e = new Exception( Message( "uncaught unknown exception" ) ); |
| 73 | result->addError( this, e ); |
| 74 | } |
| 75 | |
| 76 | try { |
| 77 | tearDown(); |
| 78 | } |
| 79 | catch (...) { |
| 80 | result->addError( this, new Exception( Message( "tearDown() failed" ) ) ); |
| 81 | } |
| 82 | } |
| 83 | catch (...) { |
| 84 | result->addError( this, new Exception( Message( "setUp() failed" ) ) ); |
| 85 | } |
| 86 | */ |
| 87 | if ( result->protect( TestCaseMethodFunctor( this, &TestCase::setUp ), |
| 88 | this, |
| 89 | "setUp() failed" ) ) |
| 90 | { |
| 91 | result->protect( TestCaseMethodFunctor( this, &TestCase::runTest ), |
| 92 | this ); |
| 93 | } |
| 94 | |
| 95 | result->protect( TestCaseMethodFunctor( this, &TestCase::tearDown ), |
| 96 | this, |
| 97 | "tearDown() failed" ); |
| 98 | |
| 99 | result->endTest( this ); |
| 100 | } |
| 101 | |
| 102 | |
| 103 | /// All the work for runTest is deferred to subclasses |