- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# ExecuteTest.h

    00001 #ifndef UNITTEST_EXECUTE_TEST_H
    00002 #define UNITTEST_EXECUTE_TEST_H
    00003
    00004 #include "TestDetails.h"
    00005 #include "MemoryOutStream.h"
    00006 #include "AssertException.h"
    00007 #include "CurrentTest.h"
    00008
    00009 #ifdef UNITTEST_POSIX
    00010 #include "Posix/SignalTranslator.h"
    00011 #endif
    00012
    00013 namespace UnitTest {
    00014
    00015 template< typename T >
    00016 void ExecuteTest ( T& testObject, TestDetails const& details ) {
    00017         CurrentTest::Details() = &details;
    00018
    00019         try {
    00020 #ifdef UNITTEST_POSIX
    00021                 UNITTEST_THROW_SIGNALS
    00022 #endif
    00023                 testObject.RunImpl();
    00024         } catch ( AssertException const& e ) {
    00025                 CurrentTest::Results()->OnTestFailure (
    00026                     TestDetails ( details.testName, details.suiteName, e.Filename(), e.LineNumber() ), e.what() );
    00027         } catch ( std::exception const& e ) {
    00028                 MemoryOutStream stream;
    00029                 stream << "Unhandled exception: " << e.what();
    00030                 CurrentTest::Results()->OnTestFailure ( details, stream.GetText() );
    00031         } catch ( ... ) {
    00032                 CurrentTest::Results()->OnTestFailure ( details, "Unhandled exception: Crash!" );
    00033         }
    00034 }
    00035
    00036 }
    00037
    00038 #endif