1

I am calling 2 web services developed by 2 different companies

first service response: {"abc":"test","xyz":""} second service response: {"foo":"USD","xyz":null}

Now I want to match the value of xyz from both services using automation. However, one service returns empty, and another returns null. Due to this test fails. Is there a way to handle this in karate?

Note: Service response cannot be changed as it's developed by 2 different companies.

Dhamo
  • 1,171
  • 3
  • 19
  • 41
kraul25
  • 127
  • 1
  • 2
  • 8

1 Answers1

1

There are at least 5 different ways to do this. Hope this get you thinking about ideas:

* def response1 = {"abc":"test","xyz":""}
* def response2 = {"foo":"USD","xyz":null}
* if (response1.xyz == '') response1.xyz = '##string'
* match response2 contains any response1

Please see this answer for more examples: https://stackoverflow.com/a/62567262/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248