我有这个Javascript对象:
{ person: { name: "john", age: 32 }}
端点返回:
{
"name": "john",
"age": 32
}
我有以下步骤:
Given path 'endpoint/'
When method get
Then status 200
And match response ==
"""
{
"name": #(person.name),
"age": #(person.age)
}
"""
这不起作用,因为#(person.name)和#(person.age)都评估为null,如何解决? (将它们放入新变量不是我要找的解决方案)
答案 0 :(得分:1)
您在这里:
* def data = { person: { name: 'john', age: 32 } }
* def response = { name: 'john', age: 32 }
* match response == data.person
由于您似乎很困惑,让我添加一下(但由于上述原因不建议这样做):
* match response == { name: '#(data.person.name)', age: '#(data.person.age)' }