Skipping lines in a datasheet

Class library usage, coding and language questions.
mattmccall
Posts: 29
Joined: Mon Nov 12, 2012 8:13 pm

Skipping lines in a datasheet

Post by mattmccall » Mon Nov 12, 2012 8:19 pm

I have one test that executes many lines in a data sheet. If a line fails I may want to skip a few rows that I know will also fail. I have been trying to find a easier way to do this than what I am currently doing.

Right now I:
1. Execute a row, and if it fails I set a couple flags
2. When the next row executes I see if the flags are set and if so I do nothing for the row

Each row is written to the log which can cause confusion.

Is there an easier way to say "go to row x in the datasheet and execute that row"?

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

Re: Skipping lines in a datasheet

Post by Support Team » Tue Nov 13, 2012 1:01 pm

Hi,

Could you please explain i detail what you are trying to do, how do you execute the lines of your data sheet?
Are you using the data driven approach?
How does your test look like?
Which Ranorex version are you using?

Regards,
Markus
.
Image

mattmccall
Posts: 29
Joined: Mon Nov 12, 2012 8:13 pm

Re: Skipping lines in a datasheet

Post by mattmccall » Mon Jan 14, 2013 5:43 pm

Just saw that there was a reply to this (I wasn't notified).

Hopefully the answers to your questions will help with my problem.

We are using data driven tests. Our tests are keyword driven, the test reads the line in the data sheet and depending on the keyword the script knows what to do. For example if the keyword is 'Login' the script logs into the application. If it's 'Create' it will create a designated item (designated by a different piece of data). We iterate through every line of the data sheet and group the entries into tests.

If during a given action like 'Create' there is an error or that action fails I do not want to do anything else. I want to skip the next one/few lines in our data sheet say down to 'Logout' because that test fails. I then want to start our next test which means I Need to skip to the start of that test which could be a few lines lower in the datasheet I am executing.

data sheet example:
TC001-login, data, data
TC001-create, data, data, data (THIS FAILS and the app is unrecoverable)
TC001-editItem, data, data, data (I want to skip this)
TC001-closeItem, data, data (I want to skip this)
TC001-logout (I want to execute this)
TC002-login, data, data
TC002-create, data, data, data
...

Currently I have handle this by setting variables that get set if the keyword fails. Then we have to use the dataconnector and datasource to iterate to the next test we want. I am just wondering if there is an easier way to look at a row/column combination and say "go to this row and execute".

Matt

mattmccall
Posts: 29
Joined: Mon Nov 12, 2012 8:13 pm

Re: Skipping lines in a datasheet

Post by mattmccall » Mon Jan 14, 2013 5:44 pm

Forgot, we are on 4.0.1 of Ranorex.

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

Re: Skipping lines in a datasheet

Post by Support Team » Tue Jan 15, 2013 2:17 pm

Hi,

Thanks for the description!
I am not completely sure you are working with Ranorex Studio and with the Test Suite, but if so you could change the error behavior of that test case to "Continue with sibling" or to "Continue with parent".
This should work it your case and should skip the next iterations of TestCase1.
For more details about this setting please take a look at the following link: Test Case Settings.
I hope this proves helpful!

Regards,
Markus
.
Image

mattmccall
Posts: 29
Joined: Mon Nov 12, 2012 8:13 pm

Re: Skipping lines in a datasheet

Post by mattmccall » Wed Jan 16, 2013 7:14 pm

Thanks for the reply. The "Continue with sibling" or "Continue with parent" will not work for us. The way our tests are structured do not allow this.

Our Ranorex Test Case (.rxtst) consists of only one test. Our Data sheet tells this test what functions/classes to call for one of our defined test cases. So we repeat this one test over and over except its not the same from data sheet row to data sheet row.

Our defined test cases are groups of rows in the data sheet. Each of our test cases are delimited by a column called TestCaseNum, and each line has a keyword that tells the .rxtst what functions/class it needs to execute. If one of these TestCaseNum/Keyword combination fails before the test case ends successfully we want to skip the remaining steps of the TestCaseNum and proceed to the TestCaseNum.

I was just wondering if there was an easier way then what I currently do that says "go to line 'x' in the data sheet".

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

Re: Skipping lines in a datasheet

Post by Support Team » Fri Jan 18, 2013 1:35 pm

Hello,

Unfortunately, there is no way no skip several lines of your data sheet.

I recommend to redesign your 'Test Suite'.
I could think of having a structure similar to the attached one.
In this case, you could use the error behavior 'Continue with iteration' if an error occurs.
Additionally, logout is executed every time since it is placed in the 'teardown region'.

Would that design meet your needs?

Regards,
Markus (T)
Attachments
Recording.JPG
Recording.JPG (32.18 KiB) Viewed 1226 times
Test.JPG
Test.JPG (21.06 KiB) Viewed 1226 times
.
Image

mattmccall
Posts: 29
Joined: Mon Nov 12, 2012 8:13 pm

Re: Skipping lines in a datasheet

Post by mattmccall » Mon Jan 28, 2013 7:31 pm

Thanks for taking time to look at this. Like I said I can do what I need to do, I was just wondering if there was an easier way.

Changing our test suite would not help and our tests would become less efficient and more difficult to use and maintain. We know we use Ranorex differently then probably everyone else and we are ok with that. :wink:

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

Re: Skipping lines in a datasheet

Post by Support Team » Tue Jan 29, 2013 5:02 pm

Hello,

You are welcome :-)
Unfortunately, I don't have an easier way for that.

Regards,
Markus (T)
.
Image

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: Skipping lines in a datasheet

Post by omayer » Wed Jan 30, 2013 3:41 pm

Hi mattmccall ,I do have similar test case design but i couldn't figure it out how to skipp couple of rows if error occurred,Please let me know if you find any easier way to to skip the rows.
-- here is my testsuite organized > console prompt to get runid from user > takes the runid value and query in db to find the scenarion > scenario has keyword which triggers the class and method > picksup the data by row the row, > couldn't figured it out an easy way to skip partial row and couple of rows
Thank you
Tipu

mattmccall
Posts: 29
Joined: Mon Nov 12, 2012 8:13 pm

Re: Skipping lines in a datasheet

Post by mattmccall » Fri Feb 01, 2013 6:07 pm

omayer,

What I do:

Create a Module Variable called PreviousTestCaseNum

then in my ITestModule.Run() I:

Create a datasource to my data sheet by data source name- var dataconn = DataSources.Get(<DAta Connector name>);

Get the row index of the data source - int rowIndex = TestCase.Current.DataContext.CurrentRowIndex - 1;

Get the test case num from the TestCaseNum field in my data sheet for the current row - string currentTestCaseNum = dataconn.Rows[Index].Values[0];

NOTE:Values[0] equals the first column in the data sheet, in our case its ALWAYS the test case number.

Then I continue to execute that row, and I do a check to see if what I am doing fails, if it does:

I set PreviousTestCaseNum = currentTestCaseNum

I also set a flagg called nextTest

Then when the next row is iterated I check to see if the nextTest is set and if so I compare previous and current test case numbers if they are different then execute the current row.


I would assume if you are just looking for ONE specific unique row to execute in your data sheet it would be a lot easier. Just get the current row identifier and keep iterating until you get the one you want.

Matt