Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)

JMeter: Using the Module Controller

One of the 7 deadly sins of the coding universe is the unnecessary duplication of code.

How can we avoid the 'deadly dupe' in JMeter? 

Sometimes one comes across a complex piece of a test plan with large amounts of used variables and functions. But, if you need to use the same segment more than once, or even twice, what can you do?

One option is to create a Bean Shell script in a separate file and to call it BeanShellSampler. But, it can be difficult to track the execution of various parts of such a complex scenario. 

Is there any other way to do it? You betcha.

It is the logic controller – Module Controller. 

The JMeter Module Controller allows switching between pieces of the test plan. Each piece is a controller that contains child elements. These controllers can either be placed in Thread Group or in Workbench.
JMeter Module Controller - JMeter Cloud Testing
The test plan contains several Simple Controllers with child HTTP Requests inside.  Simple Controller does not verify any conditions, it just combines several samples into one element. So, if the Module Controller were disabled before executing the test plan, we receive the following picture in View Results Tree.          

View Results Tree- JMeter Cloud Testing

Samples from Simple Controllers 1&2 were executed.  Now, enable Module Controller and select Simple Controller 1 therein.

Module Controller- Simple Controller- JMeter Cloud Testing

Now start the test plan again. Results below.

View Results Tree Simple Controller 1-JMeter Cloud Testing

As specified in the JMeter Manual, Module Controller can execute samples either from Thread Group or from Workbench.

Let’s verify scenario 2.

Configure Module Controller to use Simple Controller 3 that is placed in Workbench.

Samples from Workbench are executed.

View Results Tree Simple Controller 2-JMeter Cloud Testing


6 more deadly sins to go. Muah ha ha.

arrowPlease enter a URL with http(s)

You might also find these useful:

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