SoapUI如何通过Groovy脚本更新WSDL定义和重新创建请求 [英] SoapUI how to Update WSDL Definition and Recreate requests through Groovy Script
本文介绍了SoapUI如何通过Groovy脚本更新WSDL定义和重新创建请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在SoapUI中有一个肥皂测试项目.我已经将所有请求添加为测试套件中的测试步骤.
I have a soap test Project in SoapUI. I have added all the requests as test steps in a test suite.
每次启动测试时,我都需要更新WSDL定义并重新创建请求(同时保留现有值).
I need that the WSDL definition gets updated and requests get recreated (while keeping existing values) every-time i start the test.
我需要帮助,并借助一个普通的脚本自动执行此过程,该脚本可以放置在项目内部并在执行开始前每次运行.
I need help to do this process automatically with help of a groovy script that can be placed inside the project and runs every-time before execution starts.
推荐答案
现在可以正常使用了. 这是完整的代码.
Got it working now.. Here is the complete code..
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//
希望这可以帮助其他人寻找类似的解决方案.
Hope this helps others looking for similar solution.
这篇关于SoapUI如何通过Groovy脚本更新WSDL定义和重新创建请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文