I have a data driven test that currently needs the data binding altered to filter different rows for different environments. Is there a way to use a scripted step to check the environment and then run subsequent steps or skip them?
While I could hard code every step into an if else block in code, what I would like to do is simply up the iteration index and set the executioncontect.currentdatarow to the next datarow, or if I am at the end of usable datarows, to end the test without throwing a failure.
in psuedocode...
while ( Data["environment"] != CurrentEnvironment )
{
if ( Executioncontext.currentdatarow == LastDataRow )
{
end test without error
}
executioncontext.setcurrentdatarow(NextDataRow)
}
0
Stoich
Telerik team
answered on 25 Oct 2011, 10:22 AM
Hello Matthew,
I understand what you're trying to do.
You'll need to implement a workaround in order to skip an iteration:
You'll need to create two tests. Let's call them MainTest and Subtest.
Put all the automation actions in Subtest. Make MainTest data-driven. Now we're going to add Subtests as a TestAsStep in MainTest. However, we're going to do it in a coded step. Here's what the code will look like:
Copy Code
this.ExecuteTest("Subtest");
This implementation will now allow us to skip an iteration in MainTest if we so desire:
In this way if the condition you're looking for isn't met we won't go into Subtest. In effect we'll be skipping the iteration even though it won't seem so from MainTest's point of view. I hope I've managed to explain this clearly, let me know if you require additional assistance with this.
Let me know if you have additional questions on this.
Best wishes,
Stoich
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