cancel
Showing results for 
Search instead for 
Did you mean: 

Clone Existing Test Case Via Groovy Script

Highlighted
Contributor

Clone Existing Test Case Via Groovy Script

I am using soapUI via the maven plugin and I am trying to do the following:
* Get a list of something via rest
* Iterate through the list and
** Clone a test case and rename it
** Run it
** Delete it

What I am struggling with is the cloning of the test case.

I can see that you can use the code:

import com.eviware.soapui.impl.wsdl.actions.testcase.CloneTestCaseAction

def slaveTestCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite").getTestCaseByName("Name")
def ca = new CloneTestCaseAction();
ca.perform(slaveTestCase,Object)


but I can't seem to get how you can stop the prompt from appearing and just continue onto creating the test case.
3 REPLIES 3
Highlighted
Regular Contributor

Re: Clone Existing Test Case Via Groovy Script

The below code will clone a test suite named "Test" and rename it to "testing". Make the changes you need to fit your code and it should work fine. I wrote in Groovy so that I could efficiently test it but it shouldn't be difficult to grab the objects and use those functions.

def testCase = testRunner.testCase.testSuite.getTestCaseByName("Test");
testRunner.testCase.testSuite.cloneTestCase(testCase,"testing");


To better fit your code:


def slaveTestCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite").getTestCaseByName("Name")
testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite").cloneTestCase("NewName")
Remember:Questions are more important than answers.
The answer is 42 I'm a ninja!
Highlighted
Contributor

Re: Clone Existing Test Case Via Groovy Script

That's great thanks worked a treat.
Highlighted
Occasional Contributor

Re: Clone Existing Test Case Via Groovy Script

The last part will not execute because there is parameter missing in cloneTestCase().

 

Tee following lines are correct:


def slaveTestCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite").getTestCaseByName("Name")
testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite").cloneTestCase(slaveTestCase,"NewName")

 

New Here?
Join us and watch the welcome video:
Top Kudoed Authors