空手道 - 无法执行匹配操作 - 实际值不是字符串

时间:2017-09-28 14:23:48

标签: karate

Scenario Outline: Verify retreiving endpoint for particular system
  Given path 'kites/<id>'
  When method get
  Then status 200
  And match response contains "<orgid>"

  Examples:
    | kites                    | orgid                    |
    | 56338e32e4b0846c32c0732e | 56338e32e4b0846c32c0732e | 

我收到以下错误:

com.intuit.karate.exception.KarateException: path: $, actual:
{
     "orgId": "56338e32e4b0846c32c0732e",
     "name": "Supplier Management"
}
expected: '56338e32e4b0846c32c0732e', reason: actual value is not a string

我尝试使用<orgid>"<orgid>",但我遇到了同样的错误。 任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

在你的例子中,我不了解的东西太多了。 <id>来自哪里?使用kites列的位置在哪里?

最严重的问题是您使用的是orgid,但实际的JSON有一个密钥orgId。请不要犯下基本错误,然后再试一次。

你不应该尝试做这样的事情:

And match response contains { orgId: "<orgid>" }

编辑:由于有关于上述内容的抱怨(我觉得令人失望),我添加了另一个选项:

And match response.orgId == "<orgid>"