使用 Karate.mapWithKey 形成的 JSON 数组数据源时遇到“org.graalvm.polyglot.PolyglotException:ReferenceError”
我正在尝试传递 JSON 数组数据源来为我的 API 测试形成动态路径
。 我正在同一功能文件中使用 karate.mapWithKey
将现有数组(从另一个 API 和 JS 函数返回)转换为 JSON 数组。
当我打印 input
的值时,我确实看到了格式正确的对象列表,如下所示。
[
{
"keyUUID": "1234"
},
{
"keyUUID": "5678"
}
]
但是,当我运行整个功能时,我看到一个错误,如 org.graalvm.polyglot。 PolyglotException:ReferenceError:“输入”未定义
Feature: Data-Driven Feature
Scenario Outline: looping over list of json objects
* def keys = ['1234','5678']
* def input = karate.mapWithKey(keys,'keyUUID')
* print input
* When path is <name>
Examples:
| input |
我在这里遗漏了什么吗? 我尝试读取 json 文件,它工作正常,但使用 mapWithKey
创建的对象的 json 数组总是给出错误。
I am trying to pass a JSON Array Data Source to form a dynamic path
for my API tests.
I am converting an existing Array (which I get back from another APIand JS function) to a JSON Array using karate.mapWithKey
in the same feature file.
When I print the value of input
, I do see a properly formatted list of objects as below
[
{
"keyUUID": "1234"
},
{
"keyUUID": "5678"
}
]
However, when I run the whole feature, I am seeing an error as org.graalvm.polyglot.PolyglotException: ReferenceError: "input" is not defined
Feature: Data-Driven Feature
Scenario Outline: looping over list of json objects
* def keys = ['1234','5678']
* def input = karate.mapWithKey(keys,'keyUUID')
* print input
* When path is <name>
Examples:
| input |
Am I missing something here?
I tried reading through a json file , which works fine but the json array of objects created using mapWithKey
always gives an error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
input
[json 对象创建数组] 从scenariooutline
移动到Background
后,我能够解决该问题我收到的参考错误之前的
输入
现已解决。I was able to resolve it after moving the
input
[json array of objects creation] from withinscenario outline
toBackground
The reference error I was receiving earlier for
input
is resolved now.