Table of Contents

About

Variable are used to parametrize a test plan.

Scope

JMeter variables have thread scope. This is deliberate, so that threads can act independently.

Variables

Before the test start

Variables Definition

You can define an initial set of variables within:

Jmeter Test Plan Variable

All the UDV elements in a test plan - no matter where they are - are processed at the start.

User variables per Thread

Some test plans need to use different values for different users/threads.

For example, you might want to test a sequence that requires a unique login for each user.

  • Create a text file containing the user names and passwords, separated by commas.
  • Add a CSV DataSet configuration element to the test plan under a thread group
  • Give a name to the USER and PASSWORD variables in the variable name field.
  • Set the sharing mode to “All Threads”. The CSV Data Set element will read a new line for each thread.
  • Replace the login name and password on the appropriate samplers with the appropriate name variables.

Jmeter Different User Login By Thread

Command Line

You can change the values of variable on the command-line only by using a property.

After the test start

Passing variable between thread

To pass variable between thread when the value is not known until the test starts, you may use:

  • A property: Properties are shared between all JMeter threads, so if one thread sets a property , another thread can read the updated value.
  • A File: Write variables to a file and re-read them. For example you could use the Save Responses to a file listener or perhaps a BeanShell PostProcessor in one thread, and read the file using the HTTP Sampler “file:” protocol, and extract the information using a PostProcessor or BeanShell element.
  • (and write) your own Java classes

Documentation / Reference