Artem Fedorov is a Java Developer at BlazeMeter. He specializes in writing plugins for JMeter. He also develops BlazeMeter plugins for Jenkins, TeamCity and Bamboo CI. Artem maintains and develops the Jenkins Performance Plugin.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Apr 23 2018

Introducing the Set Variables Action Component in JMeter

The Set Variables Action is a new Apache JMeter™ plugin (released April. 2018). Contributed by BlazeMeter’s Java developer Artem Fedorov, the Set Variables Action sampler allows JMeter users to set different user defined variables in JMeter Thread Variables throughout a load test. This is useful if you need to parameterize your performance test.


How to Add the Set Variables Action Component


The Set Variables Action component is available to download from the JMeter Plugins Manager. You can follow the script in this blog post from here.


1. Open the JMeter Plugins Manager on JMeter (If you don’t have it, read How to Install the JMeter Plugins Manager to learn how).


2. Select the ‘Available Plugins’ tab on the JMeter Plugins Manager.


3. In the search field write ‘Set Variables’, and then select the plugin’s checkbox.


4. Click the button ‘Apply Changes and Restart JMeter’.


set variables action sampler in jmeter


How to Use the Set Variables Action Component


1. Let's create an empty test plan and add the first Thread Group to it.


2. Add a Set Variables Action sampler and a Debug Sampler to your Thread Group.


3. Add a Simple Controller to the Thread Group, then add another Set Variables Action sampler and another Debug Sampler to the Simple Controller. Let's rename this Controller to "Step 1" and copy this controller, so we now have 2 controllers, 2 debug samplers and 3 Set Variables Action samplers.


4. Go to the first Set Variables Action sampler and add 2 variables with values, e.g. "step=none" and "var=value". Go to the second Set Variables Actions sampler and add 2 variables with values, e.g. "step=1" and "var1=value". In the third Set Variables Actions sampler set the following values: "step=2" and "var2=val2".


5. Add a View Results Tree listener to the test plan to visualize results. Now your test plan should look like this:


how to use the set variable actions on jmeter


6. Run the test. Go to the View Results Tree and investigate the Response data tabs for both samples. You'll see that step and var1 had different values after each Set Variables Action.


In Debug Sampler 0 we can see that the first Set Variables Action set two JMeterVariables: step=none and var=value.


how to use the set variables action sampler in jmeter


In the second Set Variables Action, the value of the variable step was changed to the value ‘1’. The JMeterVariable var1=value was also changed. We can see this change in Debug Sampler 1.


load testing and set variables action sampler


The third Set Variables Action sampler changed the step value to ‘2’ and added a new JMeterVariable var2=val2. Look at Debug Sampler 2 in the View Results Tree.


guide for set variables action sampler


Great! You can now disable the debug sampler, add configurations for the website or app you are testing, and run your performance test. To learn more JMeter, go to the free JMeter Academy.


Running Your JMeter Test in BlazeMeter


To monitor your test results, collaborate on your test and reports, scale your test and run it easily, you can upload your JMX script to BlazeMeter.


guide for setting variables in load test


It’s easy to get started with BlazeMeter. Just click here, or put your URL in the box below and your test will start in minutes.

arrow Please enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!