我正在尝试使用Groovy脚本创建SOAPUI项目。直接从SOAPUI运行它时,脚本正常工作,并创建了使用WSDL的新项目。
脚本是在: project-> testsuite-> testcase-> groovy脚本
中创建的脚本import com.eviware.soapui.impl.wsdl.*
import com.eviware.soapui.impl.WsdlInterfaceFactory
String Release = "xxx.yyy";
String projectName = "Test_$Release" + ".xml";
String projectPath = "D:/work/";
String fullProjectPath = "$projectPath$projectName";
String pathToWSDL = "D:/work/AWSECommerceService.wsdl.xml";
log.info ("Release value is $Release");
log.info ("Projet path is $projectPath");
log.info ("Project name is $projectName");
log.info ("pathToWSDL $pathToWSDL");
log.info ("fullProjectPath $fullProjectPath");
def currentProject = testRunner.testCase.testSuite.project;
WsdlProject project = currentProject
.getWorkspace()
.createProject(projectName, new File(fullProjectPath));
WsdlInterface iface = WsdlInterfaceFactory.importWsdl(project,pathToWSDL, true )[0]
context.testCase.testSuite.project.save("");
当SoapUI
中的脚本正常工作。但是,使用testrunner.bat
运行时失败如下:
testrunner.bat "D:IvoProject.xml"
它正在返回以下错误:
错误:java.lang.nullpointerexception:null对象上的createProject()无法调用
您可以尝试如下给出的更改:
来自:
WsdlProject project = currentProject
.getWorkspace()
.createProject(projectName, new File(fullProjectPath));
to:
WsdlProject project = new WsdlProject();
project.setName(projectName);
//your statements goes here
//finally save project
project.saveAs(fullProjectPath);