空手道 - 如何检查数组是否包含值? [英] Karate - how to check if array contains values?

查看:36
本文介绍了空手道 - 如何检查数组是否包含值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了数组

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

和变量

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

如何检查数组是否包含预期?在数组的最后一个元素中有预期值,但它包含一些额外的值,这就是为什么我总是尝试检查它失败的原因.

How to check if array contains expected? In the last element of array there is expected value but it contains some additional values and thats why it failed all the time I try to check that.

推荐答案

这将在 0.9.6.RC4 中工作:

This will work in 0.9.6.RC4:

* match array contains deep expected

在以前的版本中:

* match array contains '#(^expected)'

请阅读文档:https://github.com/intuit/空手道/树/develop#schema-validation

这篇关于空手道 - 如何检查数组是否包含值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆