Forum Discussion
One way is to have a file with expected json response and compare the actual response against that file, and use script assertion for the same.
See this link how to compare (you can have the code in script assertion)
http://stackoverflow.com/questions/2253750/compare-two-json-objects-in-java
- jeffrey_crowley11 years agoContributor
Thanks for the response. I should have mentioned that I tried this at some level. I have code that compares the top level nodes in the JSON response but some of the responses run very deep and it makes it hard to determine where exactly the actual failure is. I have actually seen this link but it doesn't mention jsonSlurper or deep compares, at least without additional libraries. Is there a particular library that you would recommend? I tried finding info on how to import a library into a groovy script and I didn't find any info... so I don't know if that means it can't be done or ???
- nmrao11 years agoCommunity HeroYes, that only says if both actual and expected are matched or not which is crucial for automation.
However, you want to find the details, probably you may need to implement as per the needs.