根据空手道中的条件验证响应 xml
Validating response xml based on condition in Karate
空手道 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>
- 字符串原因='This is currency breach'
我想验证一个用例 --> if(true) match reposne contains reason
因为我有两种基于条件的消息。如果在这里匹配,我该怎么办。
给你,请阅读文档: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
空手道 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>
- 字符串原因='This is currency breach'
我想验证一个用例 --> if(true) match reposne contains reason
因为我有两种基于条件的消息。如果在这里匹配,我该怎么办。
给你,请阅读文档: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