Forum Discussion

TallGuy789's avatar
TallGuy789
New Contributor
15 years ago

Can I programmatically change an XQuery Match assertion

Hi there,

I have a large number of tests with the same SOAP request and the same XQuery Match assertion on them. The expected result matches the entire result and looks something like this:


<PerformFunctionResponse xmlns="urn:acme.services.purchase.response">
<SomeValue>123</SomeValue>
<Code>A</Code>
</PerformFunctionResponse>


(There is a whole lot of other stuff in it that I have omitted for clarity.) I want to be able to set the value of <Code> based on a configuration setting. Getting the setting is easy, but I don't know how to programmatically change the assertion.

I can change the request easily:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def xmlHolder = groovyUtils.getXmlHolder("AcmeService.PerformFunction#Request");
xmlHolder["declare namespace ns1='urn:acme.services.purchase.request';//ns1:PerformFunctionRequest/ns1:Id[text()]"] =
context.acme.Id;
xmlHolder.updateProperty(true);


How can I change assertion programmatically?

Thanks
  • Hi!

    Maybe you can use property-expansion in the expected value:

    <PerformFunctionResponse xmlns="urn:acme.services.purchase.response">
    <SomeValue>123</SomeValue>
    <Code>${#TestCase#Code}</Code>
    </PerformFunctionResponse>

    which would pick up the value of the Code property defined at the TestCase level.. (which you can change easily with a script)

    Hope this helps!

    regards,

    /ole
    eviware.com
  • TallGuy789's avatar
    TallGuy789
    New Contributor
    Awesome! That is a perfect solution Thank you very much.

    Stephen