Forum Discussion

Ganitha's avatar
Ganitha
Regular Visitor
3 years ago

how to clone single test step to multiple testcases in Ready API version 2.8

I have a test Step that needs to copied to all testcases in a suite. Clone TestStep allows me to copy to only 1 another testcase. 

 

in this process, I have to clone teststep one by one to all testcases. this is time consuming as there are around 20- 30 testcases in a suite.

 

In documentation, I saw there is a way but I am not seeing that option in version 2.8.  

  • KarelHusa's avatar
    KarelHusa
    Champion Level 2

    Ganitha ,

    you can automate this by a Groovy script:

     

    project = context.getTestCase().getTestSuite().getProject()
    step = project.getTestSuiteByName("MySuite").getTestCaseByName("MyCase").getTestStepByName("ToBeCloned")

    project.getTestSuiteList().each {
    testSuite = it

    testSuite.getTestCaseList().each {
    testCase = it
    testCase.cloneStep(step, "TheNameOfTheCloned")
    }
    }

    How it works:

    1. First get a test step you want to clone (ToBeCloned)
    2. Go through all test suites
    3. Loop through all test cases within the suite
    4. Clone a selected test step into current test case (you can set a new name)

    I recommend to do a backup of your SoapUI project.

    Then you can place this script into a Groovy script test step, modify the names a run it.

     

    Best regards,

    Karel

     

  • richie's avatar
    richie
    Community Hero
    Hey Ganitha,

    You can do it with groovy i believe.

    I can probably put the groovy together to update 1 test at a time - which wont really save you anytime (over using the embedded functionality) cos my groovy skills bite.

    Perhaps ChrisAdams or nmrao can save the day?

    On a related note, you state that more recent versions of ReadyAPI provides functionality to clone steps to multiple testcases. I didnt realise that. Ive looked in the help and i could find that in there. Could you post a link to where you saw this please? I had a quick look in help and played with the clone stel functionality, but i couldnt see how to do it on later versions.

    Cheers,

    Rich