Forum Discussion

SoapRookie's avatar
SoapRookie
Occasional Contributor
11 years ago
Solved

Run a test step multiple times

In SoapUI Pro, within a test case, is it possible to run a test step 3 times before moving to the next test step?
If so, can someone suggest how can I do this?

SoapRookie

6 Replies

  • Hello,
    You can write following groovy step to run as many times as you want.

    if( context.loopIndex == null )
    context.loopIndex = 0
    if( ++context.loopIndex < 10 )
    testRunner.gotoStepByName( "Name of TestStep to run n times" )

    Same thing can be achieved using data source loop to run as required number of times by specifying those many rows.
    But I feel groovy way is better to achieve this.
    Hope it helps.
  • SoapRookie's avatar
    SoapRookie
    Occasional Contributor
    Hi ReshmaSachdev,

    Thank you for your reply. I am a new to Groovy, but not new to programming.
    I have created a Groovy Script at the end of the test steps and entered the code suggested by you (All I did was replace the test step name, which is within braces). The script ran fine.
    And I got the output as, "INFO: Going to step[user.votePoll]

    But the Poll has not been voted multiple times. So the test step has not been ran multiple times. Do I need to add more scripting for the step to be ran multiple times? Also, how can debug this?

    Thanks for your help,
    SoapRookie
  • Hi,
    Sorry for replying late.
    Please refer the file attached to execute n - number of times a test step.
    Here in that i was trying to execute Request 1, 3 times [for understanding purpose, i have added property transfer and groovy steps to display the values], after executing n times, you can add your further steps.
    Hope it helps.