Scenario Outline: I have an audit type <type>
When a request is received
"""
{
"elements":{
"type":<type>,
"id":"sku-1"
}
"""
Examples:
| type |
| test1 |
| test2 |
| test3 |
如何用例子中给出的值替换上述问题?
答案 0 :(得分:1)
最好不要为Json使用Doc String。相反,试试这个:
Scenario Outline: I have an audit type
When a request is received of "<type>"
Examples:
| type |
| test1 |
| test2 |
| test3 |
很抱歉, Ruby 中的响应,不熟悉从String到Json对象或Hashtable 的 Java转换。但我发现这个more可能有助于管理json:
在Ruby中:
When(/^a request is received of "([^"]*)"$/) do |type|
json = eval("{'elements':{'type':'#{type}','id':'sku-1'}}")
end
首次运行时,json
将为:{'elements':{'type':'test1','id':'sku-1'}}
希望你能让它发挥作用。
答案 1 :(得分:0)
我用简单的改变
Scenario Outline: I have an audit type <type>
When a request is received
"""
{
"elements":{
"type":'<type>',
"id":"sku-1"
}
"""
Examples:
| type |
| test1 |
| test2 |
| test3 |