I'm not able to understand the dynamic data ta

2019-07-17 02:06发布

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.

标签: karate
1条回答
Juvenile、少年°
2楼-- · 2019-07-17 02:37

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.

Suppose you have a csv like this:

[data.csv]:

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

Then the following test is green

  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.

查看更多
登录 后发表回答