Groovy Script in SoapUI REST Testing

1. Run special step:

testRunner.runTestStepByName("stepName/requestName")

 get it's response:

testRunner.testCase.testSteps["stepName/requestName"].testRequest.response

 

 

2.Set property

def setProperties(Name,Value,Place)
{    
    name = Name;
    target = testRunner.testCase.getTestStepByName(Place);
    target.setPropertyValue(name,Value);
    }

 

 

3.Clean property

def cleanProperty(PropertyListName)
{
         PropertyList = testRunner.testCase.getTestStepByName(PropertyListName);
         size=PropertyList.getPropertyCount();
         if (size!=0)
         {
                   for (i=0;i<size;i++)
                   {
                            PropertyList.removeProperty(PropertyList.getPropertyAt(0).name);
                   }
         }
}

 

 

4. Get response with XMLHolder

Rest request:

import com.eviware.soapui.support.XmlHolder

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "requestName#ResponseAsXml" )

Soap request:

import com.eviware.soapui.support.XmlHolder

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "requestName#Response" )

 

你可能感兴趣的:(Groovy Script in SoapUI REST Testing)