karate - 空手道测试 - 在“匹配每个”中进行“或”匹配的任何方式?
问题描述
我有以下类似的东西。是否有可能让空手道为foo
and进行“或”匹配bar
?
含义 -foo
以fooStartWithChar
ORbar
开头barStartWithChar
And match each response ==
"""
{
foo: '#? { _.charAt(0) == fooStartWithChar}',
bar: '#? { _.charAt(0) == barStartWithChar}',
}
"""
解决方案
有时普通的旧 JS (+Java) 是你的朋友:
* def response = [{ foo: 'aa', bar: 'bb' }, { foo: 'ax', bar: 'by' }]
* def isValid = function(x){ return x.foo.startsWith('a') || x.bar.startsWith('b') }
* match each response == '#? isValid(_)'
推荐阅读
- powerapps - 在组合框中选择特定项目
- c# - 构建 Selenium Specflow 解决方案时出错
- java - 使用正则表达式解析 Java url 域
- ios - 在 iOS 上创建动画指示箭头
- android - java.lang.NoClassDefFoundError:解析失败:Lcom/sun/mail/util/PropUtil;尝试使用 javax.mail 时
- batch-file - 用于将文件移动到尚不存在的文件夹的批处理文件
- python - Groupby 对象的百分比变化(按组)
- yocto - yocto 使用主机 perl 安装打开嵌入式配方
- c++ - 我可以命名 ostream << 运算符吗?
- angular - MatTableDataSource 出现字母顺序错误