How to put “OR” operator in Karate API assertion statement

故事扮演 提交于 2019-12-14 03:58:05

问题


I would like to use "OR" operator for assertion statement in Karate API.

This is the first time I am trying to OR operator in Karate API:

 match response.items[0].type == 'Purchase' 

I would like to use an OR operator like:

 match response.items[0].type == 'Purchase' or 'Freeplay'

I have not been able to successfully execute with or statement


回答1:


Sometimes assert is the simplest option:

* def itemType = response.items[0].type
* assert (itemType == 'Purchase') || (itemType == 'Freeplay')

There are other ways, see: https://stackoverflow.com/a/57377284/143475



来源:https://stackoverflow.com/questions/57527217/how-to-put-or-operator-in-karate-api-assertion-statement

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