How to do conditional check in karate response?

穿精又带淫゛_ 提交于 2020-12-15 06:37:09

问题


Is there any way to check if object is empty then ok if not then check if it matches a fixed structure?

I mean, something like:

* def expectedDelayEntries = response.delayEntries == "{}" ? {} : '#(delayEntries)'

回答1:


Yes. Refer to the docs: https://github.com/intuit/karate#conditional-logic

Do this in 2 steps.

* def expected = condition ? { foo: '#string' } : { bar: '#number' }
* match response == expected


来源:https://stackoverflow.com/questions/50675887/how-to-do-conditional-check-in-karate-response

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!