Reputation: 1149
I have defined multiple countries at user defined variables as list:
Then in another sample i use specific country as ex: PL
What is the easiest way, based of the usage of specific country, to enter in the loop?
I know with ${__groovy(vars.get("countries") == "AR")} is possible to compare with 1 country, but how can i compare extracted country with all the countries in the list?
Upvotes: 1
Views: 41
Reputation: 167992
If you need to iterate all the countries it's better to go for the ForEach Controller, in this case you need to transform the countries
variable into the following pattern:
country_1=PL
country_2=PT
country_3=RO
If you're looking for a Groovy code to do the conversion:
Put the following code into "Script" area:
vars.get('countries').trim().split(' ').eachWithIndex { country, index ->
vars.put('country_' + ++index, country.trim())
}
Add ForEach Controller after the JSR223 Sampler and configure it like:
That's it, you should be able to iterate all the countries, defined in the countries
variable
Upvotes: 1