【问题标题】:Karate - how to check if array contains values?空手道 - 如何检查数组是否包含值?
【发布时间】:2020-12-03 07:33:30
【问题描述】:

给定

我已经定义了数组

 * def array = [ 
     {"code": "codeA", "boolValue": false, "a": 5, "c": false}, 
     {"code": "codeA", "boolValue": true, "a": 7, "c": true},
     {"code": "codeB", "boolValue": true, "a": 1, "c": false}
   ]

变量

 * def expected = { "code": "codeB", "boolValue": true }

问题

array 的最后一个元素中有expected 值。 但它包含一些额外的值,这就是为什么我尝试检查它时它一直失败的原因。

如何检查数组是否包含预期?

【问题讨论】:

    标签: arrays cucumber karate


    【解决方案1】:

    这将在 0.9.6.RC4 中工作:

    * match array contains deep expected
    

    在以前的版本中:

    * match array contains '#(^expected)'
    

    请阅读文档:https://github.com/intuit/karate/tree/develop#schema-validation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 2019-08-10
      • 1970-01-01
      • 2015-06-24
      • 2015-01-01
      • 2021-07-15
      相关资源
      最近更新 更多