如何在Soap UI中添加groovy脚本以自动更新定义?
我使用soapui来测试我的web服务。每次我想要执行我的测试请求时,我都需要更新定义。我知道可以添加groovy脚本,让WSDL自动更新。但我不知道应该在那里添加此脚本以使其正常工作。有人能告诉我每次执行请求时运行此脚本所需的步骤吗?如果双击“导航器”选项卡上的testSuite打开测试套件,您可以在窗口底部看到一个安装脚本按钮,如果单击“设置脚本”按钮,将显示一个窗口,您可以在其上添加groovy脚本,每次执行testSuite时都会首先执行此脚本: 这在测试用例中也是可能的。除了此脚本可以是groovy或javascript之外,您还可以设置要使用哪种语言来设置项目的脚本语言属性:如何在Soap UI中添加groovy脚本以自动更新定义?,groovy,soapui,Groovy,Soapui,我使用soapui来测试我的web服务。每次我想要执行我的测试请求时,我都需要更新定义。我知道可以添加groovy脚本,让WSDL自动更新。但我不知道应该在那里添加此脚本以使其正常工作。有人能告诉我每次执行请求时运行此脚本所需的步骤吗?如果双击“导航器”选项卡上的testSuite打开测试套件,您可以在窗口底部看到一个安装脚本按钮,如果单击“设置脚本”按钮,将显示一个窗口,您可以在其上添加groovy脚本,每次执行testSuite时都会首先执行此脚本: 这在测试用例中也是可能的。除了此脚本可
以下是代码:
import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateRequests
import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateTestRequests
project = testRunner.testCase.testSuite.project; //get the project reference
def ifaceList = project.getInterfaceList(); //get all the interfaces present in the project in a list
//start a loop for number of interfaces
for(int i = 0; i < project.getInterfaceCount() ; i++)
{
def iface = project.getInterfaceAt(i);
def url = iface.definition;
iface.updateDefinition( url, true); //updateDefinition(String url , Boolean createRequests)
//The above part updates the definition
//The part below recreates the requests based on updated wsdl definition
//syntax -
//recreateRequests( WsdlInterface iface, boolean buildOptional, boolean createBackups, boolean keepExisting, boolean keepHeaders )
recreateRequests(iface,true,true,true,true);
recreateTestRequests(iface,true,true,true,true);
}
//End of Script//
导入静态com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateRequests
导入静态com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateTestRequests
project=testRunner.testCase.testSuite.project//获取项目参考
def ifaceList=project.getInterfaceList()//在列表中获取项目中存在的所有接口
//为多个接口启动一个循环
对于(int i=0;i
上述代码将为项目中的所有现有请求创建备份。如果您希望仅为已修改/更新的请求创建备份,请使用以下语句<代码>iface.updateDefinition(url,false)代码>