Stop Test Execution

Class library usage, coding and language questions.
AlpeshPatel
Posts: 3
Joined: Tue Oct 14, 2014 8:39 pm

Stop Test Execution

Post by AlpeshPatel » Tue Oct 14, 2014 8:46 pm

I have 100 data rows in my test case for example. and I have to continue execution even if error occures for any of my iteration. Hence we set the "Error Behavior" as "Continue with Iteration".
This works fine.

Now I am trying to add a condition that if 5 consecutive iterations are failed and stop the test cases execution as there is no point in continuing the execution for that test cases.

Can you please help me with a command to stop test case execution? I tried to find with API help, but could not find any.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Stop Test Execution

Post by Support Team » Thu Oct 16, 2014 3:10 pm

Hello AlpeshPatel,

You could use following lines of code in order to "stop" the execution of the current TestCase:
int index = Ranorex.Core.Reporting.TestReport.CurrentTestIterationActivity.Index;
        	
            if(index > 5)
        	{
        		TestCase a = (TestCase) TestCase.Current;
        		a.ErrorBehavior = ErrorBehavior.ContinueParent;
        		throw new RanorexException("text");
        	}
Regards,
Robert
.
Image

AlpeshPatel
Posts: 3
Joined: Tue Oct 14, 2014 8:39 pm

Re: Stop Test Execution

Post by AlpeshPatel » Thu Oct 16, 2014 4:10 pm

Got it. Thanks for the reply.
Let me try. I am sure it will work.

You are asking me to change the error behaviour at runtime from next iteration to next test case.
Shouldn't we have a simple method like "Ranorex.Core.Testing.TestCase.Current.Stop"