is it possible to perform special processing in the event of an error
here's what i want my execution plan to normally do:
login to my AUT
execute test case 1
execute test case 2
execute test case 3
etc.
logoff of my AUT
IF, for whatever reason, a test case fails, i want to continue running the next test case but i want to first logoff or terminate the AUT process and then log back into the AUT. is that possible to do? if so, how?
I was hoping the OnLogError event handler might be a solution but the support website states the following about it:
Under the "Handling Exceptions in Scripts" link it talks about using the Try, Catch, Finally (for JavaScript) . that might work if the error occurs in a script routine but what if it happens on a line in a keyword test?
i think i finally figure out how to properly use the OnStopTestCase event handler to stop and restart my AUT when any test case has an error and I don't want that error to adversely impact any subsequent test cases. Generally speaking the following event handler contains the basic steps needed. Mine is quite a bit more complicated at the point where i put the commented statement "//any other stuff necessary to get the AUT where it needs to be for the next test case" but i have tested it an it works. i did have to convert some keyword tests into scripts and then copy and paste those lines into my event handler at the appropriate location and i had to be careful even then that what I copied and pasted did not contain any KeywordTest.Run statements (as explained in the SmartBear documentation for OnTestCaseStop event handler)
function GeneralEvents_OnStopTestCase(Sender, StopTestCaseParams)
{if (StopTestCaseParams.Status !== 0)
{let appProcess = Sys.WaitProcess("myappname", 500);
if (appProcess.Exists)
{
Sys.Process("myappname").Close();
Delay(3000);
appProcess = Sys.WaitProcess("myappname", 500);
if (appProcess.Exists)
{
Sys.Process("myappname").Terminate();
}
}TestedApps.myappname.Run();
//any other stuff necessary to get the AUT where it needs to be for the next test case
}
else
{
//Do the normal stuff here when StopTestCaseParams.Status === 0
}
}