Download presentation
Presentation is loading. Please wait.
Published byRudolf Burke Modified over 9 years ago
1
Advanced Assertions in soapUI Presented by Kushan Athukorala
2
Agenda XPath Match Assertion XQuery Match Asserion Script Assertions
WS-Addressing Response Assertion WS-Addressing Request Assertion
3
XPath Match Assertion Study XPath First
4
XPath Match Assertion The XPath Match assertion allows specification of an XPath expression to be evaluated against the received response message and compare its result to a predefined value. Expressions can select everything from attribute values, make Boolean evaluations or select the entire response body. XmlUnit is used internally for comparing xml elements, nodes or hierarchies
5
XPath Assertion Examples
Example1 - Validate that the result contains how many hits declare namespace ns1=' count(//ns1:Item) Example2 - Validate that the ProductGroup element always is "Book“ declare namespace ns1=' count(//ns1:ProductGroup[text()!='Book']) Example3 -Validate that DetailPageURL always starts with ' declare namespace ns1=' count(//ns1:DetailPageURL) = count(//ns1:DetailPageURL[starts-with(text(), '
6
XQuery Match Assertion
Study XQuery First
7
XQuery Match Assertion
The XQuery Match assertions is configured exactly like the XPath Math assertion described above. Difference being that the specified expression is evaluated as an XQuery expression instead This assertion is useful when you want to assert a subset of your data and for example not be dependent on other data, the data order, etc
8
Script Assertion – Using Groovy script editor
Script Assertion allows for arbitrary validations Script has access to the following objects: messageExchange : Message Exchange for the current request/response. Gives direct access to message content, HTTP Headers, Attachments, etc. context : TestRunContext running the current TestCase, this will for now always be an instance of WsdlTestRunContext log : a standard log4j Logger object available for logging arbitrary information
9
Examples Validate a certain response time
assert messageExchange.timeTaken < 400 Validate existence of a response HTTP Header assert messageExchange.responseHeaders["x-amz-id-1"] != null Validate the existence of a specific element using GroovyUtils def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( messageExchange.responseContent ) assert holder["//ns1:RequestId"] != null
10
WS-Addressing Response Assertion
Validates that the response has valid WS-A header properties.
11
WS-Addressing Request Assertion
Validates that the request has valid WS-A header properties
12
Thank You
13
USA INDIA SRILANKA UK www.virtusa.com
"Virtusa" is a trademark of the company and a registered trademark in the EU and In India. "Productization" is a service mark of the company and a registered service mark in the United States. "vRule" is a service mark of the company. For more information please contact © V I r t u s a C o r p o r a t i o n
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.