【发布时间】:2022-07-05 22:25:22
【问题描述】:
我已经阅读了多种解决方案并且对此感到厌烦。但是根据环境断言找不到任何东西。
Is it possible to use karate 'match' inside conditional statement?
我只想检查 ST 环境是否存在 userId 响应标头,因为这是基于环境的响应标头。
下面的断言通过了,但我很确定这不是正确的方法。即使我在这里传递数字代替字符串它也可以工作,并且 userId 是字符串而不是数字。
* def userId = karate.get("responseHeaders['user-id'][0]")
* if (env == 'ST') karate.match("userId == '#string'")
在下面也尝试过,许多其他选项都通过了,而其中一个应该失败,它说"userId == '#null'"
* if (env == 'ST') karate.match("userId != '#null'")
* if (env == 'ST') karate.match("userId == '#null'")
* if (env == 'ST') karate.match("userId contains 'u'")
【问题讨论】:
标签: karate