1

I am trying to compare responses from two service call(for Migration project) using Karate. In below case when I compare 2 services response then First match fails & says reason: actual value has one more key(s) than expected: {profiles={}}

When I run only second match - Second match fails & says reason: all key-values did not match, expected has un-matched keys:[links]

I was looking someway which will highlight all elements/keys which is mismatching in one go.

  • def serviceResponse1 =
{
  "userKey": "string",
  "enabled": true,
  "locked": true,
  "profile": {},
  "roles": [
    {
      "roleKey": 3,
      "name": "Role",
      "links": []
    }
  ],
  "links": [
    {
      "rel": "self",
      "href": "https://starhub1.com"
    },
    {
      "rel": "self",
      "href": "https://singtel1.com"
    }
  ]
}
  • def serviceResponse2 =
{
  "userKey": "string",
  "enabled": true,
  "locked": true,
  "profile": {},
  "roles": [
    {
      "roleKey": 3,
      "name": "Role"
    }
  ],
  "links": [
    {
      "rel": "self",
      "href": "https://starhub22.com"
    },
    {
      "rel": "self",
      "href": "https://singtel22.com"
    }`enter code here`
  ]
}

Then match serviceResponse1 == serviceResponse2

Then match serviceResponse2 == serviceResponse1

Abhinaw
  • 23
  • 2

0 Answers0