Parameterized Controller

Download

When your JMeter test plan tree becomes like a sequoia or a banyan, you start feeling yourself like a monkey in a jungle, jumping from branch to branch, trying to support this important test consistent. You really need some way to have parameterized subroutines, to reuse parts of test plan like regular programming language functions and procedures.

JMeter have out-of-box Module controller, but it has no parameters to pass to, so if you need to call repeating sequence of the same action with different parameters, your reflection in a mirror starts morphing into monkey. Parameterized Controller helps you stay human and sane.

Tutorial

Let's create empty test plan and add first Thread Group to it. Rename thread group into "Modules", right-click it and select "Disable", that's the most preferrable way to have modules container inside your test plan. Avoid using Workbench as such container.

Add a Simple Controller to Modules, then add Debug Sampler to Simple Controller. Simple Controller is now our reusable module. Let's rename it to "Reusable Module 1"

Add second Thread Group to test plan. Add two Parameterized Controllers to Thread Group.

Add one Module Controller to each Parameterized Controller. Select "Test Plan > Modules > Reusable Module 1" in both Module Controllers. Now we are re-using a module, but still without parameterization.

Go to first Parameterized Controller and add 2 variables with values, e.g. "var1=val1" and "var2=val2". Go to second Parameterized Controller and add 2 variables with values, e.g. "var1=${var2}" and "var2=val3". We defined 2 parameters, and our module will be called with their different values.

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

Run the test. Go to the View Results Tree and investigate Response data tabs for both samples. You'l see that var1 and var2 had different values inside different Parameterized Controllers.

Download Example Test Plan