Page 1 of 1

skip iteration(s) for a data drive test case

Posted: Wed May 06, 2015 1:15 am
by c676228
Hi,

I have a test case (add users) with data from an excel sheet. I want to be able to break out of the iteration if certain data in that iteration doesn't meet the criteria, say duplicated email address

action1
action2
.
.
action5
action6 is user code validation method in *.usercode.cs, if duplicate email error message UI element presents here, stop doing action7 to action 10 and start the next iteration. if not, continue with action 7 to 10 ( add this user to database)
.
.
action9
action10
How to achieve this in Ranorex?

Thanks,

Re: skip iteration(s) for a data drive test case

Posted: Wed May 06, 2015 8:17 am
by odklizec
Hi,

These action1...action10 are the actions in Recordings, right? So basically, you want to skip the remaining recording module steps if the one with UserCode fails? I believe the only way to achieve this is to convert the "remaining" steps to user code and use them as a part of the validation UserCode action. So if the validation fails, you can skip the remaining steps (using a condition in your validation code).

Here is a pseudo code explaining how your validation method should look like:

Code: Select all

    try  
    {   
      Validate.Attribute(repo.something.ViewInfo, "Text", "yourValue");
    }  
    catch (Ranorex.ValidationException)  
    {  
      return;
    }  
    action7
    ...
    action10
There is currently no way to perform conditional operations directly in recording module.

Re: skip iteration(s) for a data drive test case

Posted: Wed May 06, 2015 7:08 pm
by c676228
Hi odklizec,
Yes actions1 ... action10 are actions in Recordings.
That was I thought too since there is no direct conditional actions in recording module.
However when I try it approach
try {
//do validate
}
catch {
//do some cleanup actions
return; // return just simply terminate all the iteration including the current one, it won't go to the next //iteration
}

Re: skip iteration(s) for a data drive test case

Posted: Wed May 06, 2015 8:13 pm
by odklizec
Hi,

Make sure the test case (in which is placed your recording) has set the error behavior to "continue with iteration". Check this link for more details about error behaviors...
http://www.ranorex.com/support/user-gui ... html#c3028

Re: skip iteration(s) for a data drive test case

Posted: Wed May 06, 2015 11:59 pm
by c676228
Got it. The support guy from Ranorex pointed that out too. It works now. :D
Thanks so much.

Re: skip iteration(s) for a data drive test case

Posted: Thu May 07, 2015 6:53 am
by odklizec
You are welcome ;)