Our project demands thorough REST API testing. So we are using SOAP-UI Pro for REST web-service testing.
I want to test the following scenario:
Storing an 'XML' file and make sure that to fetch the same 'XML' file.
Need to validate 'request-XML' with response 'XML' where some 'XML-tags' are dynamic for example:
Request 'XML' is:
<c:field xmlns:c="http://iddn.icis.com/ns/core">
<c:id>http://iddn.icis.com/fields/low</c:id>
<c:version>1</c:version>
<c:created-on>2012-08-13T11:01:39Z</c:created-on>
<c:type>field</c:type>
<c:name>low</c:name>
<c:value type="integer" />
<c:description xml:lang="en">
<c:name>low</c:name>
</c:description>
</c:field>
While fetching we need to verify that we are getting the above 'XML' back.
I tried to validate by using "assert content" but its failing as the <c:created-on>2012-08-13T11:01:39Z</c:created-on>
value is changing every time we are storing it.
how to handle dynamic response 'XML' tags in 'SOAP-UI' testing ?
Note : I am new to Groovy, x-path and X-query as well as SOAP UI.
You can try to define an assertion test script with the next script, maybe this will help you
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "Request#Request" );
def holder2 = groovyUtils.getXmlHolder("Responses#ResponseAsXml")
def stringList=[]
def stringList2=[]
for( node in holder['//name] )
{
stringList =stringList+node
}
for( node2 in holder2['//name'] )
{
stringList2 =stringList2+node2
if (node2 in stringList ) assert true
else assert null
}
log.info "Request>" + stringList
log.info "result>"+ stringList2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.