Page 1 of 1
Ending Test Case Modules
Posted: Mon Nov 18, 2013 2:07 pm
by elis
Hi,
I am trying to avoid some modules to run under a test case if the first module failed to run (in my case the application didn't start correctly).
I am using the following code:
Report.Failure(ReportLevel.Failure.ToString(), String.Format("Failed to run application: {0}", appPath));
TestReport.EndTestCase();
But the actions still running after the first one failed to run.
Please help
Re: Ending Test Case Modules
Posted: Mon Nov 18, 2013 3:36 pm
by Swisside
Hello
Try the following :
if (yourcondition){
throw new Ranorex.ValidationException("Failed to start x.exe");
}
It seems using Report.Failure returns a failure for the module but keeps going with the next Recording (or Code) Module. (I wonder if it's intended by the way
)
Throwing an exception like the one above aborts the current TestCase and continues with the next one.
Regards
Boris
Re: Ending Test Case Modules
Posted: Mon Nov 18, 2013 8:31 pm
by Support Team
Swisside wrote:It seems using Report.Failure returns a failure for the module but keeps going with the next Recording (or Code) Module. (I wonder if it's intended by the way
)
It is intended.
Report.Failure allows you to report several test failures from one module, e.g. if you validate a bunch of attributes from an element or the existence of a bunch of elements.
Throwing an exception (or just returning from the module Run method) lets you end the specific module.
Regards,
Alex
Ranorex Team
Re: Ending Test Case Modules
Posted: Tue Nov 19, 2013 9:17 am
by elis
Thank you!
Throwing an exception solved the problem.
BTW - regarding the second option, could you please elaborate?
Regards,
--Eli
Re: Ending Test Case Modules
Posted: Tue Nov 19, 2013 10:09 am
by Swisside
Hello
Report.Failure allows you to show a step failed (it has to be a non mandatory step cause it will not stop executing the module) thus enabling a more detailed failure tracking when you read the report.
See the attached screenshot for an example
Regards