9

How to make a random delay between test steps with soapUI?

Serhiy
  • 4,357
  • 5
  • 37
  • 53

5 Answers5

16

Add Groovy Script step before each Request step with the next code that adds 0-9 seconds delay:

sleep(new Random().nextInt(10) * 1000)
Artem Zankovich
  • 2,319
  • 20
  • 36
  • +1 Thanks! I was searching a while.. the SOAP UI docu only stats how to add a delay for the client side (http://www.soapui.org/Functional-Testing/controlling-flow.html) – Martin Dürrmeier Jun 16 '11 at 08:29
  • 1
    In Jenkinsfile, I had to drop `* 1000` (`sleep` accepts seconds, not milliseconds). – jfs Dec 01 '20 at 06:19
4

Exactly what you're looking for is the following.

  1. Add a Delay test step.
  2. Instead of filling a fixed number i.e. 500ms, use this expresion

    ${=(int)(Math.random()*10000)}

And change the 10000 with the multiplier that best suits your test.

jezuito
  • 251
  • 3
  • 6
0

Inside delay test step specify ${=5000 + 5000*Math.random()} Which delay your request for 5s-10s.

Or you can use groovy script before each request.

Or you can run a groovy snippet to run before each test step execute. Check events.

ShiyamTJ
  • 776
  • 8
  • 10
0

Easiest way would be to add Delay step (which is inbuilt step for soapui pro) and mention the time in ms(milliseconds)

SuperMan
  • 3,532
  • 12
  • 45
  • 49
-1

Typically, it should be a "Load Test" with a defined strategy of requests :

Thread : is it concurrent tests or not (1) ?
Strategy : "Simple" in your case
Test Delay : the delay between each test run in milliseconds
Random : the relative amount of randomization for delay
         (0 = no random, 1 = all random)
Donatello
  • 3,486
  • 3
  • 32
  • 38