空手道-如何导入json数据 [英] Karate - How to import json data

查看:174
本文介绍了空手道-如何导入json数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一些JSON数据导入到我的测试中.
为了记录文档,我应该这样:

I want to import some JSON data to my tests.
In order to documentation I should do that like this:

* def data = read('classpath:init/data.json')

我创建了具有以下内容的JSON文件:

I've created my JSON file with this content:

{
    "name": "ehsan"
}

这是我的代码:

  Background:
    * def data = call read('classpath:init/data.json')

  Scenario:
    * print data

但是它什么也不打印,并说:

But it prints nothing and says:

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')

只有您必须删除[通话]

Only you must remove [call]

这篇关于空手道-如何导入json数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆