Is there a way to have multiple expected results in one assertion for one test step.
Declare:
declare namespace b="base"; //b:policies/b:policy/b:total-premium
Expected Result:
7.362*
XML Assertion code:
<con:assertion type="XPath Match" id="" name="XPath Match">
<con:configuration>
<path>
declare namespace b="base"; //b:policies/b:policy/b:total-premium
</path>
<content>7.362*</content>
<allowWildcards>true</allowWildcards>
<ignoreNamspaceDifferences>false</ignoreNamspaceDifferences>
<ignoreComments>false</ignoreComments>
</con:configuration>
</con:assertion>
<con:credentials>
<con:authType>No Authorization</con:authType>
</con:credentials>
<con:jmsConfig JMSDeliveryMode="PERSISTENT"/>
<con:jmsPropertyConfig/>
<con:wsaConfig mustUnderstand="NONE" version="200508" action="" addDefaultTo="true"/>
What I would like SoapUI to do is compare the value from total-premium
to the values of 7.362*
, 6.994*
, and 7.730*
for this specific test step and if any of them passes the test step passes.
Is that possible?
A possible way to do so is to use Script assertion
instead of Xpath match assertion
.
In the Script assertion
you can parse the response, get the node values and compare against the list of the possible values, something like:
// get the xml response
def response = messageExchange.getResponseContent()
// parse it
def xml = new XmlSlurper().parseText(response)
// find your node by name
def node = xml.'**'.find { it.name() == 'total-premium' }
// assert against the possible values
assert ['7.362*','6.994*','7.730*'].contains(node.toString())
Update
I misunderstood your question at first I think that you want to check exactly 7.362*
, and really the wildcard is for any digits, excuse me. Then you can use a regex with matches()
method to check if you value starts with some of the desired values:
// get the xml response
def response = messageExchange.getResponseContent()
// parse it
def xml = new XmlSlurper().parseText(response)
// find your node by name
def node = xml.'**'.find { it.name() == 'total-premium' }
// assert
assert node.toString().matches("(7.362|6.994|7.730)\\d*")