如何在空手道中验证JSON属性作为某个字符串返回?
在空手道测试中,我想评估JSON响应中返回的属性是否为字符串类型。 以下是在做什么:
* def abc = response.results.abc
Then match abc == "#string?"
下面的响应是得到:
实际:'狮子',预期:'#string?',原因:没有评估“ true”
请让我知道我在哪里错误的。 谢谢。
In Karate tests, I'd like to evaluate whether an attribute returned in json response is of string type.
Below is what am doing:
* def abc = response.results.abc
Then match abc == "#string?"
Below is the response am getting:
actual: 'lion', expected: '#string?', reason: did not evaluate to 'true'
Please let me know where I am wrong.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在纠正它: https://github.com/github.com/karateunabs/karate#schema-validation
建议您一次匹配JSON对象,您的测试将更加清晰。
You are overcomplicating it: https://github.com/karatelabs/karate#schema-validation
It is recommended you match JSON objects all at once, your tests will be more crisp.