【问题标题】:Getting error http request failed: null when using path in karate获取错误http请求失败:在空手道中使用路径时为空
【发布时间】:2019-05-06 13:55:43
【问题描述】:

我开始使用空手道进行测试,但是当我使用“path”关键字时,我收到“http request failed: null”错误。

当使用以下场景时,它可以工作:

Feature: items

Scenario: Testing /items response status
    Given url appBaseUrl + '/items'
    And param param1 = 1
    And param param2 = 10
    When method get
    Then status 200

但是当我尝试在下面的代码中使用“路径”关键字时,我最终得到了错误

Feature: items

Scenario: Testing /items response status
    Given url appBaseUrl
    And path 'items'
    And param param1 = 1
    And param param2 = 10
    When method get
    Then status 200
items.feature:8 - null
com.intuit.karate.exception.KarateException: items.feature:8 - null
    at ✽.When method GET (items.feature:8)

我不知道我做错了什么。是否有一些额外的步骤需要完成而我错过了?

【问题讨论】:

    标签: java karate gherkin


    【解决方案1】:

    一定有其他事情发生,因为这应该有效。试试这个例子:

    * def appBaseUrl = 'http://httpbin.org/anything'
    
    Given url appBaseUrl
    And path 'items'
    And param param1 = 1
    And param param2 = 10
    When method get
    Then status 200
    

    在我的系统上运行良好。

    所以我建议你遵循这个过程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

    编辑:这确实是一个错误:https://github.com/intuit/karate/issues/760 - 在修复之前使用karate-jersey 是一种解决方法

    【讨论】:

    • 您的示例对我有用,但是一旦我将 url 更改为 localhost127.0.0.1,我又开始收到错误。
    • 并且由于我发布的第一个代码有效,我确信服务器正在运行并正常工作
    • @Gruutak 现在只有一种方法可以证明存在问题 :) 你的举动
    猜你喜欢
    • 2013-02-08
    • 2013-04-07
    • 1970-01-01
    • 1970-01-01
    • 2015-09-27
    • 1970-01-01
    • 2019-09-26
    • 2014-04-01
    • 1970-01-01
    相关资源
    最近更新 更多