我无法理解空手道中的动态数据表方案 [英] I'm not able to understand the dynamic data tables scenarios in Karate

查看:53
本文介绍了我无法理解空手道中的动态数据表方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何使用csv文件创建动态数据表.

Anybody know how to use the csv file to create a dynamic data tables.

我正在尝试使用文档中定义的代码,但不适用于我.

I'm trying to use the Code defined in the documentation but it's not working for me.

推荐答案

read函数接受csv文件,并从csv创建一个json对象数组.总是需要标题行,并且标题用于创建对象成员的名称.

The read function accepts csv files and creates an array of json objects from the csv. Header row is always expected and the header is used to create the name of the object members.

假设您有一个这样的csv:

Suppose you have a csv like this:

[data.csv]:

[data.csv]:

name,likes
Cucuma,1
Canyon,2
Stevens,3

然后以下测试为绿色

  Scenario: Read CSV file and convert that to json
    Given json dataFromCsv = read('data.csv')
    Then match dataFromCsv ==
    """
    [
      {name : "Cucuma", likes : '1'}
      {name : "Canyon", likes : '2'}
      {name : "Stevens", likes : '3'}
    ]
    """

You can find that example here. It's a gradle and groovy based test, but I hope it helps.

这篇关于我无法理解空手道中的动态数据表方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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