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
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’.
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:
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.
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.
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.
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.
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.