Handling exceptions

If a software exception occurs in the Test member function, the Test framework catches the exception and handles it. If a hardware exception or fault occurs in the Test member function, a monitoring task can terminate the task running
the test.

If you need to capture information about an exception in the Setup, Test, or Reset member functions, override TTest::HandleException, which is called whenever an exception is caught. To capture information about an exception that occurs in the Cleanup member function, override HandleCleanupException.

Both HandleException member functions make a copy of the exception, which you can retrieve with CreateException or CreateCleanupException. You can override the HandleException member functions to be notified when an exception occurs or to repair a test after an exception to make it streamable to the log.

Tests with uncaught exceptions fail by definition; if an uncaught exception occurs, TTest::Run will call SetSuccess(false) before calling HandleException.

To get information about an exception:

  1. Override the appropriate exception handling member function, either HandleException or HandleCleanupException.
  2. In your member function, call the inherited HandelException function to make a copy of the exception that you can use.
  3. Write the code to perform what you need to do after the exception.
      void TSampleObjectBaseTest::HandleException(const TStandardException& exception)
      {
              TTest::HandleException(exception);
              OutputTextStream() << "\nHandleException!\n";
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker