【问题标题】:karate doesn't match xml obtained from function空手道与从函数获得的 xml 不匹配
【发布时间】:2019-05-21 00:20:29
【问题描述】:

我必须验证从函数中获取的 XML 片段,但匹配也会失败。

为了解释我的需求,我必须测试一个 Web 服务,作为响应,它会在正文中发送一个包含以 base64 编码的 xml 片段的肥皂消息。在我的空手道测试中,我使用函数解码该片段并使用模糊匹配进行验证,但每次匹配都失败了。

我做了一个测试,其中明确定义了 XML 'A',而 XML 'B' 是从 A == B 的函数中获得的。然后我定义了一个应该匹配两者的 XML 'C',但只匹配明确定义的。

Feature: 

Background:

* def buildXml = 
"""
function(param){ 
    return '<root><hello>world</hello><foo>bar</foo></root>';
}
"""

Scenario: 

* def a = <root><hello>world</hello><foo>bar</foo></root>
* def b = buildXml()
* def c =
"""
<root>
    <hello>world</hello>
    <foo>#ignore</foo>
</root>
"""

* match a == b
* match a == c
* match b == c

最后一场比赛失败,但应该通过。

【问题讨论】:

    标签: karate


    【解决方案1】:

    只需一点点改变,你就很好了:

    * xml b = buildXml()
    

    原因:https://github.com/intuit/karate#type-conversion

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多