Page 1 of 1

Using same data connector for nested testcases

Posted: Fri Sep 26, 2014 3:09 pm
by monkey2012
Hi Support Team,

In my solution, I have nested testcases as follows:

Main_Testcase
|-- [SETUP]
|-- Level1_Testcase1
|-- [SETUP]
|-- Level2_Testcase1
|-- Level2_Testcase2
| -- [TEARDOWN]
| -- Level1_Testcase2
|-- [SETUP]
| -- Level2_Testcase3
| -- Level2_Testcase4
| -- [TEARDOWN]
|-- [TEARDOWN]

Main_Testcase: data connector is named Main1
Level1_Testcase1: data connector is named Level1_data1
Level2_Testcase1: data connector is named Level2_data1
Level2_Testcase2: I want to use Level1_data1 but this is invisible in this testcase since its parent testcase (Level1_Testcase1) already connected to Level1_data1.

The problem is all the nested testcases can't use the same data connector once their parent testcase already connected to it.
Should Ranorex be flexible in this case so users don't need to create many duplicated data connectors.

Ranorex 5.1.2
Windows 7 32-bit

Added attachement for easy to see how testcases are organized

Re: Using same data connector for nested testcases

Posted: Fri Sep 26, 2014 3:47 pm
by krstcs
There is no way that this could work due to the way Ranorex handles data connectors. It would create circular logic in the test cases for the data connectors. How would test case A1 know which data to use if it was using test case A's same data connector?

Did you realize that a parent test case's data is available to all children?

In other words, if you bind the data connector to a parent, all children of that parent can see and work with that data.

You might need to restructure your tests.

Ranorex treats test case as big for-each loops. If you don't have a data connector, the loop is run once. If you have a connector, the loop is run for each row in the data. So, if you have sub-cases, they will be run that many times as well.

For example, if you have the following cases:

Code: Select all

TC1 -> Con1 = 4 rows of data
    TC1.1 -> Con2 = 2 rows of data
TC2 -> NO CONNECTOR
    TC2.1 -> Con2 = 2 rows of data
    TC2.2 -> Con2 = 2 rows of data (filtered to 1 row)
TC1 will run four (4) times (once FOR-EACH row in Con1), TC1.1 will run 8 times, 2 times FOR-EACH row in Con2 X 4 runs of TC1, its parent.

TC2 will run one (1) time. TC2.1 will run 2 times, using the same connector as TC1.1, which is allowed since they are not nested. TC2.2 will run 1 time on the filtered row, again using the same data set, Con2, as TC1.1 and TC2.1, allowed because 2.2 is not nested under TC2.1.


Edit to add: This FOR-EACH looping allows you to create some interesting logic if you set up your data sets correctly. You can have data sets that return zero (0) rows, causing the test case to be skipped without error. I use this with dynamic SQL queries to control the logic and flow of my tests.

Re: Using same data connector for nested testcases

Posted: Mon Sep 29, 2014 1:16 pm
by monkey2012
Hi Krstcs,

Thanks for the explanation