1
votes

Recently I have started to improve my SOAP UI testing projects by using Groovy Scripts. I am just on a beginner level more often amending and reusing scripts than creating ones of my own, hope that soon I will be able to create custom scripts :)

These days I have searched for a way to clone existing Test Steps from a Test Case into another Test Case. I have searched in the net for some ways or ready scripts that I can implement in my projects, but so far I have no luck finding what I need :(

Can you help me with this by showing me some examples how this can be done?

Kind regards, Kristiyan

2

2 Answers

3
votes

You can clone a test step (or a whole test case) from one place to another easily enough:

def originalTestStep = testRunner.testCase.testSuite.project
        .getTestSuiteByName("OriginalTestSuite").getTestCaseByName("OriginalTestCase")
        .getTestStepByName("OriginalTestStep")

testRunner.testCase.testSuite.project
        .getTestSuiteByName("TargetTestSuite").getTestCaseByName("TargetTestCase")
        .cloneStep(originalTestStep, "clonedTestStep")

But, this would be creating a maintenance problem. A better option would be to put your common test steps into a test case and then run that test case from your many other test cases. There's a Run Test Case test step you can use or you can do it from Groovy:

def testCase = testRunner.testCase.testSuite.project
        .getTestSuiteByName("CommonTestSuite")
        .getTestCaseByName("CommonTestCase")
def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
testCase.run(properties, false)

This way your maintenance is confined to just a few places.

0
votes

The GUI allows you to clone or move a test step from one test to another test.

In the folder structure on the left of the GUI, right-click the step of interest and a context menu will pop-up. Or, highlight the step and click F9.

A window should appear that asks whether you want to move or copy the step and the destination.