如何在黄瓜特征文件中表示嵌套的 json 对象
How to represent nested json objects in a cucumber feature file
我需要在功能文件中表示 JSON 对象。我可以为此使用 json 文件来获取代码。但这意味着我无法从功能文件传递值。
Scenario: Test
Given a condition is met
Then the following json response is sent
| json |
| {"dddd":"dddd","ggggg":"ggggg"}|
以上适用于正常 json。但是,如果有嵌套对象等,那么像上面那样在一行中写 json 会使该功能非常难以阅读和修复。
请告诉我。
您可以使用字符串来做到这一点,它使 json 更清晰。
Then the following json response is sent
"""
{
'dddd': 'dddd',
'ggggg': 'ggggg',
'somethingelse': {
'thing': 'thingvalue',
'thing2': 'thing2value'
}
}
"""
代码中可以直接使用:
Then(/^the following json response is sent$/) do |message|
expect(rest_stub.body).to eq(message)
end
或类似的东西。
我需要在功能文件中表示 JSON 对象。我可以为此使用 json 文件来获取代码。但这意味着我无法从功能文件传递值。
Scenario: Test
Given a condition is met
Then the following json response is sent
| json |
| {"dddd":"dddd","ggggg":"ggggg"}|
以上适用于正常 json。但是,如果有嵌套对象等,那么像上面那样在一行中写 json 会使该功能非常难以阅读和修复。
请告诉我。
您可以使用字符串来做到这一点,它使 json 更清晰。
Then the following json response is sent
"""
{
'dddd': 'dddd',
'ggggg': 'ggggg',
'somethingelse': {
'thing': 'thingvalue',
'thing2': 'thing2value'
}
}
"""
代码中可以直接使用:
Then(/^the following json response is sent$/) do |message|
expect(rest_stub.body).to eq(message)
end
或类似的东西。