我的用例是使用示例实现方案概述,而我的小型Api返回一个我想参数化的json输出。
我的用例就像
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"} |
她的问题是示例,它被当作字符串使用,因此匹配失败并显示错误:正在尝试比较响应 {“ id”:“#present”}和“ {” id“:”#present“}”失败 从示例中读取内容时,可以通过任何方式将其返回json。 帮助将不胜感激。 谢谢
答案 0 :(得分:1)
在列名称后添加!
。请参阅: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"} |