Page 1 of 1

Killing Executable With Muliple Arguments

Posted: Thu Aug 26, 2010 12:17 am
by costamesakid
I have error handling in my test runners as:

catch (ImageNotFoundException e)
{
Report.Error(e.ToString());
Report.LogData(ReportLevel.Error, "Image not found", e.Feature);
Report.LogData(ReportLevel.Error, "Searched image", e.Image);
error = -1;
}
catch (RanorexException e)
{
Report.Error(e.ToString());
Report.Screenshot();
error = -1;
}
catch (ThreadAbortException)
{
Report.Warn("AbortKey has been pressed");
Thread.ResetAbort();
error = 1;
}
catch (Exception e)
{
Report.Error("Unexpected exception occured: " + e.ToString());
error = -1;
}


Then I pass the error code to Program.cs where I display some custom dialog boxes depending on the error code:

//Display Error Dialog if an Error Occurs or Success Dialog if Test Completes Without Errors
if (error == -1)
{
CommonUtilLib.Util.MsgBox.Show("An Error Has Occurred, Test Aborted.","Test Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (error == 0)
{
CommonUtilLib.Util.MsgBox.Show("Test Successfully Executed","Test Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (error == 1)
{
CommonUtilLib.Util.MsgBox.Show("You Have Aborted the Test","Test Aborted", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}


This works fine when I run my projects executable with 1 argument. But if I string multiple arguments together and then Ranorex errors on one test, the executable will remain running and begin executing the next test. Is there anyway to kill the exe when an error occurs during playback, instead just logging the error and continuing to the next test? Thanks

Re: Killing Executable With Muliple Arguments

Posted: Thu Aug 26, 2010 8:06 am
by sdaly
How about:

If error < 2 Then End

Re: Killing Executable With Muliple Arguments

Posted: Thu Aug 26, 2010 10:41 am
by Support Team
costamesakid wrote:But if I string multiple arguments together and then Ranorex errors on one test, the executable will remain running and begin executing the next test
Well, I guess that you have to change the code that starts the individual recordings/executables and check the return value of the recording/executable. If it's an error, then don't start the next executable/recording.

Don't know how your code looks like that starts the individual recordings, but it should not be too difficult to add a check for the returned error code.

Regards,
Alex
Ranorex Team