How do I code to quit current test case and continue?

Class library usage, coding and language questions.
dochoa
Posts: 29
Joined: Tue Jul 16, 2013 11:36 pm

How do I code to quit current test case and continue?

Post by dochoa » Tue Jul 15, 2014 12:41 am

Hello,

Here is my current code:

Code: Select all

if (LangToAdd.Equals(""))
        	{
        		Ranorex.Report.Info("Step Skipped For Iteration", "No Additional Languages specified");
        		throw new Ranorex.RanorexException("No Additional Languages specified");
        	}
        	else
I don't like this part because I can't get it to end without putting an error in my report.

What line of C# code can I use instead of:
throw new Ranorex.RanorexException("No Additional Languages specified");
that will just quit the current test case and move on to the next one?

Playing with error behavior is not working for me.

Thank you

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How do I code to quit current test case and continue?

Post by krstcs » Tue Jul 15, 2014 1:29 pm

Ranorex uses exceptions for failures of any kind, so if you throw an exception and don't catch it, Ranorex will fail the test. This is how Ranorex is designed. If you don't want failures then you will need to catch the exception before it is thrown back up the stack with a try..catch block.

As to quitting test cases early, you could data-drive your test so that the part that is only expected in certain cases is enclosed in it's own test case whose data is blank for the cases where you don't want anything done. Then you can wrap your module code in an "if(!dataVariable.Equals("")) { //do something }". There are several other ways to do it, but they involve either a lot of code or a lot of SQL, or both.
Shortcuts usually aren't...

dochoa
Posts: 29
Joined: Tue Jul 16, 2013 11:36 pm

Re: How do I code to quit current test case and continue?

Post by dochoa » Tue Jul 15, 2014 5:05 pm

Thanks again, krstcs.

I did use the "if(!dataVariable.Equals("")) { //do something }". but it is not working for the current scenario.

So there is nothing like "Ranorex.Core.TestCase.Exit" or an equivalent?

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How do I code to quit current test case and continue?

Post by krstcs » Tue Jul 15, 2014 6:20 pm

Here is a link to the Ranorex API for your info: http://www.ranorex.com/Documentation/Ranorex/
Shortcuts usually aren't...