【发布时间】:2021-10-14 19:56:32
【问题描述】:
我们来自这里:https://github.com/intuit/karate#match-contains-deep
正如它所说:
这会修改 match contains 的行为,以便处理嵌套列表或对象以进行“深度包含”匹配,...,您只想检查各种数据“树”中的某些值
所以让我们试着玩一下,找到一些 {e: 5},它会在树的某个深处,当original = { a: 1, b: 2, c: 3, d: { a: 1, b: 2, e: 5 } }
Feature: Match contains deep
# match contains deep test (works ok, but this is not "deep" by any stretch of imagination, this is guiding the whole path in the search)
Scenario: match contains deep test modified original
* def original = { a: 1, b: 2, c: 3, d: { a: 1, b: 2, e: 5 } }
* def expected = { d: { e: 5 } }
* match original contains deep expected
#Thats was not deep, this is deep (fails, and this is what anyone would understand by "deep")
Scenario: match contains deep
* def original = { a: 1, b: 2, c: 3, d: { a: 1, b: 2, e: 5 } }
* def expected = { e: 5 }
* match original contains deep expected
#So you dont need deep (fails)
Scenario: match contains test modified original without deep
* def original = { a: 1, b: 2, c: 3, d: { a: 1, b: 2, e: 5 } }
* def expected = { d: { e: 5 } }
* match original contains expected
#So maybe it works with any (fails)
Scenario: match contains test modified original
* def original = { a: 1, b: 2, c: 3, d: { a: 1, b: 2, e: 5 } }
* def expected = { e: 5 }
* match original contains any expected
#Maybe I'm tripping with syntax (fails)
Scenario: match contains deep test my test #2
* def original = { a: 1, b: 2, c: 3, d: { a: 1, b: 2, e: 5 } }
* def expected = e: 5
* match original contains deep expected
#So maybe I'm tripping with syntax and semantics, and its any (fails)
Scenario: match contains deep test my test #2
* def original = { a: 1, b: 2, c: 3, d: { a: 1, b: 2, e: 5 } }
* def expected = e: 5
* match original contains any expected
所以,要么我没有真正得到这个东西,要么它没有按预期工作,即我想检查放置在树中任何位置的现有键值对。
如果有人能对此有所启发,那就太好了。正如我所看到的,@PeterThomas 正在回答大多数带有空手道标签的问题,我要感谢他为将这个工具交到社区手中所做的巨大努力。
【问题讨论】:
标签: karate