Forum Discussion
chathurad
7 years agoContributor
i came up with this
import com.eviware.soapui.support.XmlHolder import net.sf.*; import net.sf.json.*; import net.sf.json.groovy.*; def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) //Getting response from methods def response = context.expand( '${Validate valid responce code#Response}' ).toString() def slurper = new JsonSlurper() def json = slurper.parseText response def countryList= json.result.country
Now my
countryList
looks like an array.
So now have to assert whether each elemant on countryList is equal to "New Zelan".
But how to do that?
- JHunt7 years agoCommunity Hero
countryList.each { assert it == "New Zealand" }
- JHunt7 years agoCommunity Hero
Or...
// ...
def json = slurper.parseText response json.result.each { assert it.country == "New Zealand" } - chathurad7 years agoContributor
After some times when working with differnt dfate i found that when the data set is blank also this assertion get pass.
countryList.each { assert it == "New Zealand" }
For the moment my countryList is blank.
But it says assertion passed.
Is there any way to fix my code?
- JHunt7 years agoCommunity Hero
You can have multiple assert statements in the one script assertion:
assert countryList.size() > 0 countryList.each { assert it == "New Zealand" }
Related Content
- 3 years ago
- 5 years ago
- 7 years ago
Recent Discussions
- 5 days ago