Working with Test Scripts |
If you catch exceptions in your test script, you are intercepting the exceptions before TestManager can become aware of them. If you handle the exception and take no other action, the script continues to run, and TestManager could log a Pass result for the script.
If an exception occurs and the script does not contain exception handling logic, the test script stops running, the next script in the suite is run, and TestManager logs a Fail result for the script and a description of the exception.
If you want to catch certain exceptions but you want the log to reflect a Fail result for the test script, use one of the Test Script Services logging methods to log the Fail result.Alternatively, consider catching the exception, logging an informative error message (that says, for instance, what you were trying to do in the script when the exception was thrown), and then re-throwing the exception to pop out of the script.
The following is an example of a catch block that re-throws an exception:
catch(Exception e { System.err.println("Exception handled in method"); throw e; // Re-throw for further processing
Rational Test Script Services for Java | Rational Software Corporation |
Copyright (c) 2003, Rational Software Corporation | http://www.rational.com support@rational.com info@rational.com |