我在 SoapUI 中有一个肥皂测试项目。我已将所有请求作为测试步骤添加到测试套件中。
我需要在每次开始测试时更新 WSDL 定义并重新创建请求(同时保留现有值)。
我需要借助 groovy 脚本自动执行此过程,该脚本可以放置在项目中并在每次执行开始前运行。
最佳答案
现在开始工作了.. 这是完整的代码..
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//
希望这可以帮助其他人寻找类似的解决方案。
关于groovy - SoapUI 如何通过 Groovy 脚本更新 WSDL 定义和重新创建请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28447452/