我想将一些 JSON 数据导入到我的测试中。
为了记录我应该这样做:
* def data = read('classpath:init/data.json')
我已经使用以下内容创建了我的 JSON 文件:
{
"name": "ehsan"
}
这是我的代码:
Background:
* def data = call read('classpath:init/data.json')
Scenario:
* print data
但它什么也没打印并说:
16:11:30.898 [main] WARN com.intuit.karate - not a js function or feature file: read('classpath:init/data.json') - [type: JSON, value: com.jayway.jsonpath.internal.JsonContext@7d61eccf]
最佳答案
下面的代码是正确的:
* def data = read('classpath:init/data.json')
只有你必须删除 [call]
关于json - Karate - 如何导入 json 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47035817/