[英]Karate: is it possible to match the json from scenario outline
My use case is to have a Scenario Outline implemented with examples and my small Api returns a json output which I want to parameterize.我的用例是用示例实现一个场景大纲,我的小 Api 返回一个 json output 我想参数化。
My use case is something like我的用例类似于
Scenario Outline : test
Given url "http://myurl.com"
And params {"id": "<id>"}
When method get
Then match response == "<schema>"
Examples:
| id | schema |
| 123 | {"id":"#present"} |
| 456 | {"id":"#present", "name":"test"} |
| 789 | {"id": "#present", "value":"#present"} |
The problem her is examples are taken as string so the match fails here with error: as it is trying to now compare the response {"id":"#present"} with "{"id":"#present"}" and fails Any way to case it back to json when reading from examples.她的问题是示例被视为字符串,因此匹配在此处失败并出现错误:因为它现在正在尝试将响应 {"id":"#present"} 与 "{"id":"#present"}" 和从示例中读取时,以任何方式将其转换回 json 失败。 Help would be appreciated.
帮助将不胜感激。 Thank you
谢谢
Add a !
添加一个
!
after the column name.在列名之后。 Refer: https://github.com/intuit/karate#scenario-outline-enhancements
参考: https://github.com/intuit/karate#scenario-outline-enhancements
Scenario Outline : test
Given url "http://myurl.com"
And params {"id": "#(id)"}
When method get
Then match response == schema
Examples:
| id! | schema! |
| 123 | {"id":"#present"} |
| 456 | {"id":"#present", "name":"test"} |
| 789 | {"id": "#present", "value":"#present"} |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.