您的位置:首页 > 产品设计 > UI/UE

Groovy Script in SoapUI REST Testing

2015-09-28 13:38 661 查看
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" )
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: