Re: Compare two REST API responses for every attribute (node
Hi
How can I compare two json responses in ready api i.e.,I have a url I have requested a response1 and received response1. Now I have created another step in the same test case with the same parameters and requested response2 and received the response2.
NOW
I want to I want to compare RESPONSE1 with RESPONSE2.
Is it possible..?? If yes please reply me asap.
Thanks
Rana
Hello, It is possible to compare two JSON responses.
Simplest approach is to parse the response using JsonSlurper and assert.
import groovy.json.JsonSlurper
def Response1 = context.expand( '${#TestStepName#Response}' ).toString()
JSON1 = new JsonSlurper().parseText Response1def Response2 = context.expand( '${#TestStepName#Response}' ).toString()
JSON2 = new JsonSlurper().parseText Response2assert JSON1 == JSON2