Reputation: 137
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.
Upvotes: 1
Views: 3612
Reputation: 58088
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
Upvotes: 1