我从空手道api调用中获取的响应XML如下
<?xml version="1.0" encoding="UTF-8"?>
<response>
<header>
<node>
<p n="CURRENCY">USD</p>
<p n="REASON">This is a currency breach</p>
</node>
</header>
</response>
我要验证用例-> if(true)匹配回执包含原因
因为我有两种基于条件的消息。如果在这里匹配,该怎么办。
答案 0 :(得分:0)
您在这里,请阅读文档:https://github.com/intuit/karate#conditional-logic
* def response =
"""
<?xml version="1.0" encoding="UTF-8"?>
<response>
<header>
<node>
<p n="CURRENCY">USD</p>
<p n="REASON">This is a currency breach</p>
</node>
</header>
</response>
"""
* def condition = true
* def expected = condition ? 'This is a currency breach' : 'blah'
* match /response/header/node/p[@n='REASON'] == expected