If the verification fails in a test case with only one verification statement, usually an exception is raised and the test case is terminated. However, if you want to perform more than one verification in a test case, before the test case terminates, this approach would not work.
testcase MultiVerify () TextEditor.Search.Find.Pick () Find.VerifyCaption ("Find") Find.VerifyFocus (Find.FindWhat) Find.VerifyEnabled (TRUE) Find.Cancel.Click ()
The test case contains three verification statements. However, if the first verification, VerifyCaption, fails, an exception is raised and the test case terminates. The second and the third verification are not executed.
testcase MultiVerify2 () TextEditor.Search.Find.Pick () do Find.VerifyCaption ("Find") except ExceptLog () do Find.VerifyFocus (Find.FindWhat) except ExceptLog () Find.VerifyEnabled (TRUE) Find.Cancel.Click ()
All the verifications in this example are executed each time that the test case is run. If one of the first two verifications fails, the 4Test function ExceptLog is called. The ExceptLog function logs the error information in the results file, then continues the execution of the script.
testcase VerifyTest () STRING sTestValue = "xxx" STRING sExpectedValue = "yyy" CompValues (sExpectedValue, sTestValue) CompValues (STRING sExpectedValue, STRING sTestValue) do Verify (sExpectedValue, sTestValue) except ErrorHandler () ErrorHandler () CALL Call LIST OF CALL lCall lCall = ExceptCalls () Print (ExceptData ()) for each Call in lCall Print("Module: {Call.sModule}", "Function: {Call.sFunction}", "Line: {Call.iLine}")
Silk Test Classic also provides the function ExceptPrint, which combines the features of ExceptCalls, ExceptData, and ExceptNum.
Testcase VerifyTest - Passed *** Error: Verify value failed - got "yyy", expected "xxx" Module: Function: Verify Line: 0 Module: except.t Function: CompValues Line: 121 Module: except.t Function: VerifyTest Line: 112
The second line is the result of printing the information from ExceptData. The rest of the lines show the processing of the information from ExceptCalls.
This test case passes because the error was handled locally and not re-raised.