【问题标题】:How to put "OR" operator in Karate API assertion statement如何在空手道 API 断言语句中放置“或”运算符
【发布时间】:2022-01-18 16:51:40
【问题描述】:

我想在空手道 API 中使用“OR”运算符进行断言语句。

这是我第一次尝试在空手道 API 中使用 OR 运算符:

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

我想使用 OR 运算符,例如:

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

我一直无法成功执行 with or 语句

【问题讨论】:

标签: karate


【解决方案1】:

有时assert 是最简单的选择:

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

还有其他方法,见:https://stackoverflow.com/a/57377284/143475

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    相关资源
    最近更新 更多