Ask general questions here.
-
elis
- Posts: 15
- Joined: Sun Nov 10, 2013 10:27 am
Post
by elis » Mon Nov 18, 2013 2:07 pm
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

-
Swisside
- Posts: 92
- Joined: Thu Oct 10, 2013 10:40 am
Post
by Swisside » Mon Nov 18, 2013 3:36 pm
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
A simple thank you always does wonders !
-
Support Team
- Site Admin

- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
-
Contact:
Post
by Support Team » Mon Nov 18, 2013 8:31 pm
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
-
elis
- Posts: 15
- Joined: Sun Nov 10, 2013 10:27 am
Post
by elis » Tue Nov 19, 2013 9:17 am
Thank you!
Throwing an exception solved the problem.
BTW - regarding the second option, could you please elaborate?
Regards,
--Eli
-
Swisside
- Posts: 92
- Joined: Thu Oct 10, 2013 10:40 am
Post
by Swisside » Tue Nov 19, 2013 10:09 am
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
You do not have the required permissions to view the files attached to this post.
A simple thank you always does wonders !