This is a migrated thread and some comments may be shown as answers.

Dynamic Data-binding

11 Answers 226 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 02 Sep 2010, 10:20 AM
I have what seems like a simple situation that I need to test, and I'm having trouble getting the Telerik tools to do what I need.  I may be missing something entirely (and I hope I am), can someone shed some light please?

My test needs to:
navigate to the site
log in
search for a user
process some details for the user
log off
log in as someone else
search for the same user
verify that the results of the processing are displayed
log off

This needs to repeat 4 times, for 4 slightly different outcomes, with identical test steps.  The only difference is the customer detail that I am searching for.  I have the tests recorded as above, as seperate tests, each being run as a "test as step" from a main test (this is just one of potentially thousands of use cases, hence the need for re-usable test chunks).  If I data-bind the search step, then it just searches 4 times in a row, and moves on with the 4th user selected.  If I data-bind the main test, there doesn't seem to be any way to pass that data in to the child test.  Someone at Telerik has suggested that this is possible with coded steps, but I cannot find any documentation on coded steps, and so I don't quite know what functionality I have available.  I have played with this a little, but the data properties appear to be read-only, with no methods to alter them.  Can anyone suggest how I can get dynamic data to a test each time I call it?

I have even tried creating an instance of the test class in code, and setting custom properties on it directly, but this has hit a brick wall as it seems that the test class has no direct "Execute" method (just one that takes a path and runs from file, not from the instantiated object).  If I've overlooked something here, this would probably be the preferred solution.

Thanks,
Richard Hensman

11 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 03 Sep 2010, 11:45 AM
No ideas from anyone out there?  I'm still hitting a brick-wall on this one, and it's a fairly crucial ability for us to have.

Any suggestion welcomed.

Richard
0
Konstantin Petkov
Telerik team
answered on 03 Sep 2010, 12:04 PM
Hi Richard,

That sounds like a typical use of data source inheritance in a TestAsStep test data bound scenario. For the test we expose an InheritParentDataSource property that you can check in the properties of the test (Project View - Properties of selected test, look for the Data category). Once that property is checked the sub test will get the data source the parent test runs so you can use a single data table dedicated for both the parent and the sub test. The sub test "assumes" it is data-driven should it inherit the parent data source so no explicit binding needed is needed for that.

All the best,
Konstantin Petkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard
Top achievements
Rank 1
answered on 03 Sep 2010, 12:48 PM
Thanks Konstantin,

I'll give that a try when I have a chance, but my instinct is that this means that the child test will have all 4 rows of data (as if the datasource was only present in the child test) and hence will loop 4 times before continuing to the next child test.  Am I right?

Rich
0
Konstantin Petkov
Telerik team
answered on 03 Sep 2010, 01:00 PM
Hello Richard,

Assuming you:
  • Have 4 rows in the data
  • The parent test is data-bound to that data
  • The child test inherits the data source
  • And you bind test steps in the parent and the child tests accordingly.

Running the parent test should execute 4 iterations as expected.

I have attached a sample test running over google.com. The parent test data resides in a built-in grid. The test should pass for all the iterations which number matches the data row count.

All the best,
Konstantin Petkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard
Top achievements
Rank 1
answered on 03 Sep 2010, 01:59 PM
Excellent, that did exactly what I was hoping for... the child test inherits the current data row, not the entire data source, so doesn't "nested loop" itself.  That's perfect.

Now to push my luck... if I want to data-bind the login steps as well so I can re-use the same test, I would need to pass different data to the two calls _within each iteration_.  Is it possible to inherit part of a DataRow, or even to artificailly move to the next row within the parent test so the correct data gets passed each time?

Richard

0
Konstantin Petkov
Telerik team
answered on 03 Sep 2010, 02:10 PM
Hi Richard,

I'm glad that helped.

You can get access to the entire data in the code a customize your data-bound step there. Just convert that step into code and look for the Data property. You can also obtain the current data row index via the following code:

this.ExecutionContext.DataSource.Rows.IndexOf(this.ExecutionContext.CurrentDataRow);

Please let us know if you need further assistance.

Kind regards,
Konstantin Petkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Brinda
Top achievements
Rank 1
answered on 12 Jan 2011, 10:13 PM
Hi Konstantin,

Your post mentions a property = InheritParentDataSource to be used to ensure the subtest uses the parent's data source. I do not see any such property exposed on the test. Here is a snapshot. Please show me how to modify the data source of a test.

Using: Telerik Test Studio, version 2010.3.1213

Regards,
Brinda
0
Keaegan
Telerik team
answered on 12 Jan 2011, 11:23 PM
Hello Brinda,

Sorry for interjecting here. The item Konstantin references (InheritParentDataSource) is the setting available within QA edition. Its location within Dev edition is slightly different. To get to it in Dev edition:

  1. Open VS and the solution in question
  2. Open Test View
  3. Click the test in Test View you want to modify in this manner
  4. Use the provided screenshot to locate the InheritParentDataSource line item, and toggle it to True
Please let us know if you continue to experience issues locating this item within Developer Edition.

Kind regards,
Keaegan
the Telerik team
Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
0
Brinda
Top achievements
Rank 1
answered on 10 Feb 2011, 08:26 PM
Thanks Keaegan. That definitely helped and was used immediately
0
dan
Top achievements
Rank 1
answered on 04 Nov 2016, 04:44 PM

Hi,

Let's say I have a main test, 'testA' that data drives 'testB' from its local data grid. Now testB calls of a number of other tests, some of which inherit the data from testA's data grid. One of testB's tests, testC, is also used in several other main tests throughout my project.

Now, in other test scenarios I have testC inherit the data from the main test, but in this particular scenario I want testC to use data from its local grid or at least from testB's local data.

How can I achieve this without having to change testC's inheritance property? I have observed that a test's local Data Grid is ignored when the InheritParentDataSource is checked. Do I need two versions of testC; one with inheritance 'on', the other 'off'?

 

Thanks,

dan

0
Elena
Telerik team
answered on 09 Nov 2016, 01:06 PM
Hi Dan,

In case you do not want to change the property whether the test should inherit its parent test data, you would need two versions of test C of your example. Here are some more examples for multi-level data bound tests

Do not hesitate to contact us in case of any further queries! 

Regards,
Elena Tsvetkova
Telerik by Progress
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Brinda
Top achievements
Rank 1
Keaegan
Telerik team
dan
Top achievements
Rank 1
Elena
Telerik team
Share this question
or