Forum Discussion

richie's avatar
richie
Community Hero
6 years ago

How to Assert Repeating Json Attributes Have The Same Value?

Hey!   I am testing a REST service and some of my GET request's Query Parameters actually appear as an attribute in my .json response (obviously) filtering the request.     e.g. if request is...
  • nmrao's avatar
    nmrao
    6 years ago

    richie ,

     

    Thank you.

     

    Below is the script assertion which will fetch all the VersionNumber's from data array and check each value is 1

     

    assert context.response, 'Response is empty or null'
    def json = new groovy.json.JsonSlurper().parseText(context.response)
    assert json.data.VersionNumber.every{1 == it}