【问题标题】:Karate : can dynamic-csv.feature work for Get Request, how to pass dynamic path parameters from CSV? [duplicate]空手道:dynamic-csv.feature 可以用于 Get Request,如何从 CSV 传递动态路径参数? [复制]
【发布时间】:2020-10-03 13:18:33
【问题描述】:

尝试从 CSV 传递动态路径参数以获得 GET 方法。

参考Karate: how to pass dynamic path parameters?

我们正在尝试从 CSV 文件的路径中传递动态参数,但是当方法为 GET 时它不能正常工作,尽管对于 POST 我们使用 CSV 没有问题。

此处借助开放 API 进行详细说明

Feature: Get users details based on valid and invalid inputs from csv file

  Background:

  * url 'https://reqres.in'

    Scenario Outline: Get single user based on id value - Valid & invalid
      Given path '/api/users/<id>'

      When method <method>
      Then status <status>

      * print response
      ##* match response.data.id contains <id>

      Examples:
        |id|status|method|Scenario|
        |2|200|GET|Valid id as input|
        |4|200|GET|Valid id as input|
        |5|200|GET|Valid id as input|
        |&|404|GET|Special character as Input|
        | |404|GET|Empty space as Input|
        |A|404|GET|Alphabet as input|
        |999|404|GET|Invalid Number as input|
        |-1|404|GET|Invalid Number as input|

这很好用,但是当我尝试通过跟随传递相同的数据时它不起作用

  |read('../../Data/users.csv')|

这就是这个 CSV 的样子 users data csv file

【问题讨论】:

    标签: karate cucumber-jvm


    【解决方案1】:

    从给出的数据很难说,it doesn't work 也无济于事。也许特殊字符会导致问题。最好遵循这个过程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

    一般来说,我不鼓励在否定情况下使用 Scenario Outline。一些指导可以在这里找到:https://stackoverflow.com/a/54126724/143475

    要对 CSV 进行故障排除,您可以尝试 * print __row 查看每一行中的值。

    这对我有用:

    Scenario Outline:
    * url 'https://httpbin.org'
    * path 'post'
    * request __row
    * method post
    
    Examples:
    | read('test.csv') |
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 2020-06-07
      • 1970-01-01
      • 2011-11-24
      • 2015-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多