空手道:是否可以匹配场景大纲中的 json

Karate: is it possible to match the json from scenario outline

我的用例是用示例和我的小 Api returns 一个 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 。 帮助将不胜感激。 谢谢

在列名后添加一个!。参考: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"} |