Killing Executable With Muliple Arguments
Posted: 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
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