空手道测试-以任何方式在“匹配每个”中进行“或”匹配吗?

问题描述 投票:0回答:2

我有类似以下内容。是否可以让空手道为foobar做“或”匹配?

含义-foofooStartWithChar开头或barbarStartWithChar开头

And match each response ==
    """
    {
      foo: '#? { _.charAt(0) == fooStartWithChar}',
      bar: '#? { _.charAt(0) == barStartWithChar}',
    }
    """
karate web-api-testing
2个回答
0
投票

有时是普通的旧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(_)'

0
投票
* def nameStartsWith = function(x) { return x.foo.charAt(0) == fooStartWithChar || x.bar.charAt(0) == barStartWithChar}
And match each response == '#? nameStartsWith(_)'
© www.soinside.com 2019 - 2024. All rights reserved.