Killing Executable With Muliple Arguments

Class library usage, coding and language questions.
costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Killing Executable With Muliple Arguments

Post by costamesakid » Thu Aug 26, 2010 12:17 am

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

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Killing Executable With Muliple Arguments

Post by sdaly » Thu Aug 26, 2010 8:06 am

How about:

If error < 2 Then End

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Killing Executable With Muliple Arguments

Post by Support Team » Thu Aug 26, 2010 10:41 am

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