void TestSuite::run_case( ITestCaseFactory& test_case_factory, ITestListener& test_listener, TestResult& test_case_result) const { test_case_result.signal_case_execution(); try { auto_ptr<ITestCase> test_case(test_case_factory.create()); test_case->run(test_listener, test_case_result); if (test_case_result.get_assertion_failure_count() > 0) test_case_result.signal_case_failure(); } catch (const ExceptionAssertionFailure&) { test_case_result.signal_case_failure(); } #ifdef NDEBUG catch (const exception& e) { TestListenerHelper::write( test_listener, *this, test_case_factory.get_name(), __FILE__, __LINE__, TestMessage::TestCaseFailure, "an unexpected exception was caught: %s.", e.what()); test_case_result.signal_case_failure(); } catch (...) { TestListenerHelper::write( test_listener, *this, test_case_factory.get_name(), __FILE__, __LINE__, TestMessage::TestCaseFailure, "an unexpected exception was caught (no details available)."); test_case_result.signal_case_failure(); } #endif }
void TestSuite::run_case( ITestCase& test_case, ITestListener& test_listener, TestResult& test_case_result) const { test_case_result.signal_case_execution(); try { // Run the test case. test_case.run(test_listener, test_case_result); // Report a test case failure if one or more assertions failed. if (test_case_result.get_assertion_failure_count() > 0) test_case_result.signal_case_failure(); } catch (const ExceptionAssertionFailure&) { test_case_result.signal_case_failure(); } #ifdef NDEBUG catch (const exception& e) { TestListenerHelper::write( test_listener, *this, test_case, __FILE__, __LINE__, TestMessage::TestCaseFailure, "An unexpected exception was caught: %s.", e.what()); test_case_result.signal_case_failure(); } catch (...) { TestListenerHelper::write( test_listener, *this, test_case, __FILE__, __LINE__, TestMessage::TestCaseFailure, "An unexpected exception was caught (no details available)."); test_case_result.signal_case_failure(); } #endif }