我有一个 json 文件,我在其中设置变量,我有 CSV 文件来读取它的值。我如何使用 intuit 空手道轻松地做到这一点?

I have a json file where I am setting variables and I have CSV file to read value from it .How can I use intuit Karate to do it easily?

我有 json 个文件如下。

   {
book : {bookId : '<bookId>' , 
         bookName : '<bookName>'
         },
staff : {
     sfattid : '<sfattid>',
     name : '<name>'
     },
libraryMember : { 
libMembId : '<libMembId>',
name : '<libraryMember>'

         }
}

我有以下 CVS enter image description here

CSV 文件,其中 headers 作为 json 文件中的上述变量。我想在场景大纲 table 中使用 CSV 文件并设置值 JSON 文件。你能推荐一些自动读取 json 的代码吗?为每一行设置相应的值。

我在想下面的代码应该可以工作,但它不工作

特点:场景大纲使用动态table 来自 csv 文件

Scenario Outline: staffname name: <name>
    * text jsonPayLoad = call read('readJson.feature')
    Given url 'http://localhost:8089/'
    And path 'returnBook'
    And request jsonPayLoad
    When method post
    Then status 200
    Then match karate.jsonPath(response,"$.status") ==  '<status>' 
    Examples:
    | read('bookreturn.csv') |

read('bookreturn.csv') 的值应该是 JSON 个对象。

例如本例中:https://github.com/intuit/karate#dynamic-scenario-outline

进行此更改:

Background:
    * def kittens = [{name: 'Billie'}, {name: 'Wild'}]