Open a screen in the app
Interact with the screen which runs a data import from either a text file or an sql data base
Restore the text fil /database so that the process can be repeated continuosly
However if there is an error I want the test to stop
1 I have set each test case in the test suite to Error Behaviour stop
2 One of my colleagues wrote a piece of code which coudl be copied into Program.cs which re runs the test suite again and again until you pause so I've used this
3 I've added new Ranorex exceptions in my code modules so that if the script fails it should generate an exception
When I ran the test suite the test would stop at the failure but then restart. So my initial thought was to add a try catch for Ranorex Exception. Then I added a setting to that the initial run would only start if x = true and then within the try catch reset the value to false
However finally having debugged it appears that the Ranorex exception isn't even getting into the catch hence the suite keeps running. What have I done wrong? I'm sure it's something obvious but I'm too close to spot it
Thank you
Example of the Program.cs code
Code: Select all
bool continuerun= true ;
do
{
//Output to the console how many iterations through the CSV imput file //Otherwise you have to abort the test to see how many iterations were performed
IterationCount ++;
Console.BackgroundColor = ConsoleColor.Magenta;
Console.WriteLine("Starting Iteration " + IterationCount.ToString());
Console.BackgroundColor = ConsoleColor.Black;
//run the Solution
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
Thread.Sleep(1000);
}
catch (ThreadAbortException)
{
error = -99;
Console.WriteLine("Thread aborted");
continuerun =false;
break;
}
catch (RanorexException e )
{
error =-1 ;
Report.Error("Ranorex exception occurred: "+ e.ToString());
continuerun =false;
break;
}
catch (Exception e)
{
Report.Error("exception occurred: " + e.ToString());
//if testrun aborted via Pause key
if(e is ThreadAbortException)
{
error = -1;
Report.Error("User has aborted thread: " + e.ToString());
continuerun = false;
break;
}
else
{
//otherwise report an unexpected exception
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
continuerun =false;
break;
}
}
finally
{
}
//Stop looping indefinitely if the user has quit the test run (via Pause key)
if (TestSuiteRunner.RunAborted == true)
{
continuerun =false;
//Teardown.Start();
break; //Quit the While Loop
}
}
while (continuerun!=false);
return error;
Example of Ranorex Exception
Code: Select all
if ((Record)==(0))
{
repo.OperationDataDataImport.OperationDataContainer.ButtonCancel.Click();
Report.Log(ReportLevel.Failure, "Fail","There are no Records for data import");
throw new RanorexException("Test is stopped due to reported error");