Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter generating same random number for each iteration

Tags:

jmeter

I've got some user defined variables to which I allocate a random number using:

${__Random(1,100)}

I then run my test using 1 thread for 5 iterations. JMeter generates the same random number for each iteration.

How do I generate a new random number for each iteration?

like image 786
ratsstack Avatar asked Oct 27 '25 07:10

ratsstack


2 Answers

User Defined Variables is a configuration element which means that:

  1. It is processed before any other elements
  2. It is processed once

So just use this __Random() function directly where required.

enter image description here

If you need to re-use the value in more than one place - amend your function call like:

${__Random(1,100,myValue)}

and after that declaration you will be able to refer random generated value as ${myValue}

enter image description here

like image 145
Dmitri T Avatar answered Oct 29 '25 07:10

Dmitri T


Add as first step of Thread Group a Flow Control Action

Put inside it a pre processor called User Parameters and click Add Variable

And put in it what you currently have in User Defined Variable

User Defined Variable

like image 29
UBIK LOAD PACK Avatar answered Oct 29 '25 05:10

UBIK LOAD PACK