在这里,我想澄清一下如何为动态JSON索引大小创建动态示例表。
我的JSON看起来
Env -2服务器
"response": {
"abc": [{
"status": "pass"
.
.
},
{
"status": "pass"
.
.
}
]
}Env -UAT-3服务器
{
"response": {
"abc": [{
"status": "pass"
},
{
"status": "pass"
},
{
"status": "pass"
}
]
}
}我的场景大纲看起来像
Scenario Outline: validating .....
When def result = callonce read('featurefilename@tagname')
Then print result
And print <status>
And print ...
And match ....
Examples:
|result.response.abc|上面的错误:
( 1) *动态表达式评估failed:result.response.abc
2) com.intuit.karate.karateExpresion:-- javascript评估失败的result.response.abc,ReferenceError:“结果”未在第1行中定义
注意:如果我将def result = callonce读取(‘功能文件名@tagname’)移到后台时,它正按预期的方式工作,但由于其他因素,无法在我的功能文件中使用背景。
提前感谢
发布于 2019-10-11 04:16:53
您可以在空手道中使用动态场景大纲特性,而不是在表中提供索引。
在这种情况下,您可以将变量作为输入传递给Examples。如果上面提供的JSON来自变量result,那么,
Examples:
| result.response.abc |请参考文档以获得更多的见解。
https://stackoverflow.com/questions/58333759
复制相似问题