Search code examples
groovysoapuitest-runner

How to import testsuite to Soap UI using groovy


I am trying to automate creation of project using simple groovy script. I have managed to create new project, import wsdl, but i am stuck with the import of testsuite. Testsuite was exported from another project and it is in .xml file This is what i have so far:

import com.eviware.soapui.impl.wsdl.*  
import com.eviware.soapui.impl.WsdlInterfaceFactory

String ProjectName = "D:/work/Project/testProject.xml";
String TestWSDL = "D:/work/WSDL/AWSECommerceService.wsdl";
String tstTestSuite = "D:/work/testSuites/suite.xml";

log.info ("Path to WSDLs:");
log.info ("TestWSDL - $TestWSDL");

log.info ("Path to testSuite:");
log.info ("testsuite- $tstTestSuite");


def currentProject = testRunner.testCase.testSuite.project;
WsdlProject project = new WsdlProject();
WsdlInterface iface1 = WsdlInterfaceFactory.importWsdl(project,TestWSDL, true )[0]
//Import of testsuite should go here
project.saveAs(ProjectName);

Solution

  • It seem to be simple to use an existing test suite file into a project using importTestSuite method.

    Here is the snippet to achieve the same.

    project.importTestSuite(new File(tstTestSuite))