【问题标题】:Random errors when matching strings [duplicate]匹配字符串时出现随机错误[重复]
【发布时间】:2021-09-12 18:50:52
【问题描述】:

通常匹配效果很好,但我最近遇到了奇怪的随机匹配错误:

$.userInfo | not equal | match failed for name: 'phone' (MAP:MAP)
{"givenName":"##string","familyName":"##string","phone":"##string"}
{"givenName":"Andreas","familyName":"Conroy","phone":"+19515554384"}

$.userInfo.phone | not equal (STRING:STRING)
'##string'
'+19515554384'

'+19515554384'怎么不是字符串?

谢谢

【问题讨论】:

    标签: karate string-matching


    【解决方案1】:

    听起来您的“预期”与“实际”数据混淆了。以下是您可以剪切和粘贴的 2 行代码,并验证它是否有效:

    * def response = {"givenName":"Andreas","familyName":"Conroy","phone":"+19515554384"}
    * match response == {"givenName":"##string","familyName":"##string","phone":"##string"}
    

    【讨论】:

    • 好的,就是这样......颠倒了实际/预期。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-16
    • 2016-07-19
    • 1970-01-01
    • 2013-08-31
    • 1970-01-01
    相关资源
    最近更新 更多