Skip to content

Random Variable

Configure the JMeter Random Variable configuration elements: properties, defaults, and practical usage notes for building reliable load tests.

Difficulty
intermediate
Guide type
reference
Estimated read time
2 min read
Last verified version
Verified JMeter 5.6

Part of the Configuration Elements category. Also documented in context in the full Component Reference.

Random Variable

The Random Variable Config Element is used to generate random numeric strings and store them in variable for use later. Itโ€™s simpler than using User Defined Variables together with the [__Random()](/functions/random/) function.

The output variable is constructed by using the random number generator, and then the resulting number is formatted using the format string. The number is calculated using the formula minimum+Random.nextInt(maximum-minimum+1). Random.nextInt() requires a positive integer. This means that maximum-minimum - i.e. the range - must be less than 2147483647, however the minimum and maximum values can be any long values so long as the range is OK.

NameRequiredDescription
NameYesDescriptive name for this element that is shown in the tree.
Variable NameYesThe name of the variable in which to store the random string.
Format StringNoThe java.text.DecimalFormat format string to be used. For example โ€œ000โ€ which will generate numbers with at least 3 digits, or โ€œUSER_000โ€ which will generate output of the form USER_nnn. If not specified, the default is to generate the number using Long.toString()
Minimum ValueYesThe minimum value (long) of the generated random number.
Maximum ValueYesThe maximum value (long) of the generated random number.
Random SeedNoThe seed for the random number generator. If you use the same seed value with Per Thread set to true, you will get the same value for each Thread as per Random class. If no seed is set, Default constructor of Random will be used.
Per Thread(User)?YesIf False, the generator is shared between all threads in the thread group. If True, then each thread has its own random generator.
On this page