Forum Discussion

Srikantha87's avatar
Srikantha87
New Contributor
15 years ago

Using assertion in groovy script

Hi

How can i call or use my assertions in my groovy script.

I want to call assertions in my Groovy code.

Please let me know the function.

Thanks and Regards,
Srikantha

2 Replies

  • Finan's avatar
    Finan
    Frequent Contributor
    You want to use the soapUI assertions available per response, or you want to create your own assertions, or do you want to validate in groovy?

    Regardless of the answer, I'd suggest the api
  • Aaronliu's avatar
    Aaronliu
    Frequent Contributor
    Hi Srikantha
    may be you can refer to some articles through link first below
    http://learnsoapui.wordpress.com/
    you also can find the related presentation in soapui online document.
    for example:
    you want to add some script assertion to determine if the value return is correct

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    /*get xmlHolder*/
    def responseHolder = groovyUtils.getXmlHolder( messageExchange.responseContent )
    /*get namespace*/
    responseHolder.namespaces['ns1']='http://www.webservicex.net';
    def placeName=responseHolder.getNodeValue("//ns1:GetWeatherByPlaceNameResponse[1]/ns1:GetWeatherByPlaceNameResult[1]/ns1:PlaceName[1]")
    log.info placeName


    Regards,
    Aaron