Module Controller

By | 2020-09-29T17:03:30+00:00 September 29th, 2020|Tags: , , , |

Module Controller in Apache JMeter is crucial and frequently used in planning the load test of any software. In this article, we will take a look at how we can make our JMeter scripts with Module Controller.

Why exactly do we need this controller?

The general idea in load testing is that tests consist of a small functionality (i.e. Sign In, Create Account, Log Out…). This functionality can be stored as “modules” in the Controller (i.e. Simple Controller, Loop Controller, if Controller …). The Module Controller will choose which module should be run. Module controller allows you to redirect test execution to a given fragment or controller of the test. That’s why we use the Module Controller.

To understand the Module Controller in a simpler way, let’s explain it with a short example.

Our scenario is the “login”, “add product to basket”, “go to basket” then “log out” steps that are frequently used in e-commerce sites.

We can develop these steps without using a module controller, but if we do not want to go to the basket without logging in to the scenario, we can use a module controller.

Let’s develop this script in JMeter.

First, we create a template,

In this scenario, we will use a simple controller to divide the steps into modules, that’s why we are adding the Simple Controller.

To understand whether the login service is working successfully or not, we can use the following code block provided by JMeter into the If Controller.

module controller

(${JMeterThread.last_sample_ok})

Then we put the module controller into the IF controller and after entering the IF block, we

choose where to direct it.

And run this script..

As you can see above, when login was not successful, it entered the module controller in the IF block and redirected it to login again.