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’:
How to add a βRandom Variableβ in JMeter?
You can follow the steps to add the random variable configuration element:
- Select the ‘Test Plan’ node
- Right-click on the ‘Test Plan’ node
- Mouse over ‘Add’
- Move your mouse over ‘Setting Item’
- 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.