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
Any suggestion welcomed.
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
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
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
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
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
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
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:
- Open VS and the solution in question
- Open Test View
- Click the test in Test View you want to modify in this manner
- Use the provided screenshot to locate the InheritParentDataSource line item, and toggle it to True
Keaegan
the Telerik team
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
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
Test Studio Trainings