rana1
8 years agoNew Contributor
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 parame...
- 8 years ago
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