Skip to content

User Defined Variables

Configure the JMeter User Defined Variables 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.

User Defined Variables

The User Defined Variables element lets you define an initial set of variables, just as in the Test Plan.

So you cannot reference variables which are defined as part of a test run, e.g. in a Post-Processor.

UDVs should not be used with functions that generate different results each time they are called. Only the result of the first function call will be saved in the variable. However, UDVs can be used with functions such as [__P()](/functions/p/), for example:

HOST \${__P(host,localhost)}

which would define the variable โ€œHOSTโ€ to have the value of the JMeter property โ€œhostโ€, defaulting to โ€œlocalhostโ€ if not defined.

For defining variables during a test run, see User Parameters. UDVs are processed in the order they appear in the Plan, from top to bottom.

For simplicity, it is suggested that UDVs are placed only at the start of a Thread Group (or perhaps under the Test Plan itself).

Once the Test Plan and all UDVs have been processed, the resulting set of variables is copied to each thread to provide the initial set of variables.

If a runtime element such as a User Parameters Pre-Processor or Regular Expression Extractor defines a variable with the same name as one of the UDV variables, then this will replace the initial value, and all other test elements in the thread will see the updated value.

NameRequiredDescription
NameNoDescriptive name for this element that is shown in the tree.
User Defined VariablesNoVariable name/value pairs. The string under the โ€œNameโ€ column is what youโ€™ll need to place inside the brackets in \${โ€ฆ} constructs to use the variables later on. The whole \${โ€ฆ} will then be replaced by the string in the โ€œValueโ€ column.
On this page