How to add assertion for HTTP 204 content in REST

2019-05-29 21:27发布

When I run the REST request, my response is

HTTP/1.1 204 No Content Date: Fri, 01 Oct 2010 17:18:11 GMT X-Response-ID: 10016

How to verify this? Because it is header i guess. How to add assertion for this? When i decloare

标签: rest
2条回答
孤傲高冷的网名
2楼-- · 2019-05-29 22:10

You can use the method messageExchange.responseHeaders[field] to access the HTTP header fields like #status*, Content-Type, Accept etc.

def http_status = messageExchange.responseHeaders["#status#"][0]
assert http_status.contains("204")
查看更多
男人必须洒脱
3楼-- · 2019-05-29 22:15
import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
def node = holder.getDomNode( "//data[1]/@contentType" )

assert node != null
assert((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["#status#"]).containsValue("HTTP/1.1 204 No Content")
查看更多
登录 后发表回答