Random Variable

JMeter – Random Variable

The ‘Random Variable’ configuration element in JMeter is used to create random integer values for each iteration within a given range. A string that is stored as a string in a variable and the generated value can be combined. See the screenshot below, where ‘rand_CustomerID’ is a random variable that stores a string value like ‘custXXXXX’, where XXXXX is a random value between ‘1’ and ‘99999’:

JMeter - Random Variable

How to add a β€˜Random Variable’ in JMeter?

You can follow the steps to add the random variable configuration element:

  1. Select the ‘Test Plan’ node
  2. Right-click on the ‘Test Plan’ node
  3. Mouse over ‘Add’
  4. Move your mouse over ‘Setting Item’
  5. Click on ‘Random Variable’

What are the ‘Random Variable’ input fields?

“Random variable” has the following input fields:

1. Name: specify the name of the element

2. Feedback – to provide random feedback (if any)

3. Variable Name: The name of the variable to store the generated random value. The value can be called anywhere in the test script with the same variable name. Example: ${rand_CustomerID}.

4. Output format: You can specify the string format. In the above example; if the value 12345 is randomly generated, cust12345 is the string. If nothing is specified, the randomly generated value is passed as is.

5. Minimum Value: The minimum value of the range of random numbers.

6. Maximum Value: The maximum value of the range of random numbers.

7. Seed for random function: The seed for the random number generator. The default is the current time in milliseconds. By supplying the seed, you tell JMeter to generate the random value in the same order on each test.

8. Per Thread (User): If ‘False’, the generated value will be shared among all threads in the thread pool. If True, then each thread has its value.

Scroll to Top