2
votes

I want to know If I can create a new project using Groovy script. What is have tried so far is :

  1. Created a sample project manually in Soap UI, added a Test suite, test case and a groovy test step with the following script

    import com.eviware.soapui.impl.wsdl.*  
    import com.eviware.soapui.impl.WsdlInterfaceFactory
    
    WsdlProject project = new WsdlProject()
    project.setName("Test")
    WsdlInterface iface = WsdlInterfaceFactory.importWsdl(project, "path pointing to some wsdl", true )[0]
    WsdlOperation operation = iface.getOperationByName( "MyOperation" )
    WsdlRequest request = operation.addNewRequest( "My request" )
    request.setRequestContent( operation.createRequest( true ) )
    
  2. Run the step

But I am not able to create a project out of it. Can someone help me with what I am missing or going wrong?

1
Why do you want to do that way while it is easy to create using the tool in a second? What are you trying to achieve? And why is it tagged to java then? - Rao
I want to automate everything straight from creating project to running it. Java tagged by mistake. - Chandan Gupta

1 Answers

2
votes

If I can create a new project using Groovy script

Yes, definitively.

what I am missing

The newly project should be added to a workspace, at least the workspace of the current project.

Try this:

def currentProject = testRunner.testCase.testSuite.project

String projectName = "foo"
WsdlProject project = currentProject
                        .getWorkspace()
                        .createProject(projectName, new File(projectName + ".xml"));

References