is it possible to perform special processing in the event of an error
- 2 years ago
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
}
}