Forum Discussion

Fanch's avatar
Fanch
New Contributor
7 years ago

Loop testcase only once

Hello,

 

I'm fairly new to groovy in SOAPUI. I have a testcase composed of 8 steps. I want to run all of the steps once again a second time. I tried a Groovy stepatthe end with 

 

(0..1).each {
testRunner.gotoStepByName("Create mission")
}

 

but it loops continuously. What should I change in that script?

 

Thanks for any help.

 

--

Fanch

 

 

4 Replies

  • avidCoder's avatar
    avidCoder
    Super Contributor

    Try below code:-

     

    def loop = 0
    while (loop <= 2 ){ 

    //Add all the steps here
    testRunner.runTestStepByName("Create mission")
    loop = loop + 1
    }

    log.info 'Loop End'

     

    Hope this will help you to resolve your problem.

  • Fanch's avatar
    Fanch
    New Contributor

    Oh hello, I didn't even get a notification for your reply. Where in my testcase should I place this script?

    Is that a groovy step before all the other steps?

    • avidCoder's avatar
      avidCoder
      Super Contributor

      Create one groovy script at the very first step and copy this whole code.. And mention all the steps you want to run. Automatically it will call all the steps and will run it 2 times as mentioned in loop.