Forum Discussion
KarelHusa
9 years agoChampion Level 1
I would suggest to loop at the test case level.
1. you define properties on TestSuite (or TestCase) level:
- airports with value: London,Prague,Paris
- counter with value: 0
2. create a 'Flight' TestStep and in your test step get the airport value and increment the counter:
def s = testRunner.testCase.testSuite.getPropertyValue( "airports") def list = s.split(',') def i = Integer.parseInt(testRunner.testCase.testSuite.getPropertyValue( "counter")) // Do your action here log.info list[i] // increment the counter i++ testRunner.testCase.testSuite.setPropertyValue( "counter", i.toString())
3. Put a Groovy script test step called 'Continue ' afterwards, with a script:
def s = testRunner.testCase.testSuite.getPropertyValue( "airports") def list = s.split(',') def i = Integer.parseInt(testRunner.testCase.testSuite.getPropertyValue( "counter")) if (i < list.size()) { // Looping as long as we have values testRunner.gotoStepByName ('Flight') } else { // Otherwise we set counter to initial value testRunner.testCase.testSuite.setPropertyValue( "counter", new Integer(0).toString()) }
3. This code prints following output:
Thu Aug 04 14:26:53 CEST 2016:INFO:London
Thu Aug 04 14:26:53 CEST 2016:INFO:Paris
Thu Aug 04 14:26:53 CEST 2016:INFO:Prague
I hope this helps, however the looping is not on a TestSuite level. TestSuite level looping is also possible, you need to utilize the TestSuite TearDown script for looping.
- sathyaraj9 years agoOccasional Contributor
Thanks for the suggestions.i will try and update
Related Content
- 3 years ago
- 9 years ago