Clone Existing Test Case Via Groovy Script
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014
08:27 AM
10-15-2014
08:27 AM
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:
but I can't seem to get how you can stop the prompt from appearing and just continue onto creating the test case.
* 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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014
09:46 AM
10-15-2014
09:46 AM
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.
To better fit your code:
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!
The answer is 42 I'm a ninja!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2014
12:53 AM
10-16-2014
12:53 AM
That's great thanks worked a treat.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2019
11:22 PM
05-15-2019
11:22 PM
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")
