Forum Discussion
tjdurden
14 years agoFrequent Contributor
Hi dlizarazo,
It would appear that you're not iterating over this correctly. I have made some minor alterations as follow, but you'll see, by running the step, that you're not iterating, and not getting a value for the counter:
Some things to bear in mind:
1. I believe any property is treated as a string field, so if you're going to increment Counter by 1, you may have to convert/cast as an integer.
2. You will probably need to have a setup script to handle the creation of your array data and initial values. Likewise, you'll need the same on a teardown, otherwise you'll have to manually reset the property values when re-running the test.
3. Rather than iterate based upon a counter, why don't you count the values in the array, and use a iterate on a for loop, or similar? I've provided an implementation of this at viewtopic.php?f=5&t=15500&sid=51f34fddfdaf8e72f4801b3ba013947c#p37045
Kind regards,
Tim
It would appear that you're not iterating over this correctly. I have made some minor alterations as follow, but you'll see, by running the step, that you're not iterating, and not getting a value for the counter:
def itemList =[2020,1009,2035];
def counter = 0;
def myItem = new java.util.Properties();
myItem = testRunner.testCase.getTestStepByName("PropertyValues");
def thisItem = itemList[counter];
def thisCount = counter++;
//myItem.setPropertyValue("ItemId",thisItem);
//myItem.setPropertyValue("Counter",thisCount);
log.info("ItemId property set to: " + thisItem);
log.info("Counter property set to: " + thisCount);
Some things to bear in mind:
1. I believe any property is treated as a string field, so if you're going to increment Counter by 1, you may have to convert/cast as an integer.
2. You will probably need to have a setup script to handle the creation of your array data and initial values. Likewise, you'll need the same on a teardown, otherwise you'll have to manually reset the property values when re-running the test.
3. Rather than iterate based upon a counter, why don't you count the values in the array, and use a iterate on a for loop, or similar? I've provided an implementation of this at viewtopic.php?f=5&t=15500&sid=51f34fddfdaf8e72f4801b3ba013947c#p37045
Kind regards,
Tim