This is a continuation of my
previous post (Load Testing: Logic Controllers in JMeter (Transaction, ForEach, If)). Here I show some other useful logic controllers
1. Include
Controller: This helps using same steps across test plans. Suppose you save
several test plans and each of them requires you to login to the system. Adding
login steps in each test plan is not worthy. Rather you can use include
controller as described below.
a.
Create a test plan that contains a Test Fragment
and all the steps related to login within it as shown below
c. Open a different test plan where you want to use
this login steps. And add an include controller in place of login steps and
provide the file name of the login test plan that you have created in previous
steps.
That’s
it. Steps from the file as mentioned here will be execute as part of this test
plan.
2. Loop
Controller: As the name suggests, it
allows you to loop through steps. Use of it is pretty straight forward. Just
add you steps within a loop controller and asks the loop controller how many
times it needs to loop through the steps.
3. Interleave
Controller: This is not used very often but can be useful sometimes. It allows
you to execute alternate steps within a loop. Suppose you have 3 pages that
user visits. And you want your test to tool 10 times for these pages.
Additionally you want your test to execute only one of those three pages in
every loop. You can use Interleave controller in this context as shown below
4. Module
Controller: This allows you to reuse logic controllers within a test plan.
Suppose you are visiting a page in your test plan. And it comprises of some
HTTP requests, assertions etc. And all these are consolidated with a logic
controller. And suppose during the course of load testing you are visiting the
same page again within the same test plan. You may not want to repeat the same
steps here again. So you can take the help of module controller to refer to
that logic controller here. Shows below how you can accomplish that
a.
Get all the steps, you think will repeat, in a
single logic controller.
b.
Add a Module Controller to a place where you
want the above steps to repeat. And select the logic Controller from ‘Module To
Run’ dropdown in module controller.
5. Once
Only Controller: This, when applied within a loop, executes the associated
steps only once across the loops. Suppose, you have a loop and it consists of
several steps. You want one of the steps to execute only once when the test is looping
across. This is pretty simple. Just add once only controller within the loop
and add the steps in it.
Here the steps associated with ‘Transaction
Controller: Home Page’ will be executed only once within the loop.