Itay Mendelawy is Product Manager at BlazeMeter. Prior to joining BlazeMeter, Itay was a Sysadmin and Devops consultant at Devops Israel, focusing on the development of agile and devops methodologies. Itay also spent several years as a programmer and integrator at Bank Hapoalim for CyberArk products designing and developing systems for secure server management. Itay began his career with 5 years as a Systems IT/Programmer in the Israeli Defense Forces.

Become a JMeter and Continuous Testing Pro

Start Learning
Slack

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)

How to Manage Large JMeter Scripts With JMeter Test Fragments

By default, JMeter scripts tend to be complex! But there are some great solutions that can help you. JMeter offers test fragmenting to minimize the amount of code in scripts and make them easier to maintain. It also allows you to add various modules to tests, in which they can be run on the same file. To make this process smoother, Blazemeter also supports test fragmenting, and provides a feature that enables multiple colleagues to collaborate by sharing folders that include the test fragments created in JMeter.
 

Running Multiple JMeter Functions

 

There are two common scenarios where it’s useful to run multiple functions on one load script. These are:

Scenario 1: Working on Modules Simultaneously

 

Test fragments can be an effective solution if two engineers are needed to work on separate modules simultaneously - but the modules can be incorporated into one load test. For example, if you have an ecommerce website, you may have two complex modules - one module for browsing, and another for the checkout function. You need the ability to assign two engineers to work on the script at the same time, where one works on the browsing scenario, and the other on the shopping scenario. You then run the script that yields the results, including these two modules.

 

Scenario 2: Creating a Different Flow With Multiple Modules

Utilizing test fragments is also beneficial if you have a very complex system with many modules. You can modify the root and diffusers for each module, and create a flow between them. You can avoid creating a script per scenario as all of the load tests for your modules are scripted in different files, including a separate file that controls the flow between them. Think of it like programming the load tests. In essence, functions that are actually load tests for modules are created, and the way that the functions interact with each other can be adjusted. Test fragmenting provides the means to create a different flow for your load test.

 

Creating Test Fragments in JMeter

To create a test fragment, let’s refer to our first example where two engineers are working on modules simultaneously for the ecommerce website. Two test fragments are created -- ‘browse’ and ‘shop’. To create a test fragment, just right click on 'Test Plan', click ‘Add’, then click ‘Test Fragment’, and, again, click ‘Test Fragment’.

 

 

 

Add a test fragment

 

Then, inside of the test fragment, each performance engineer can create the flow needed for each specific module by adding separate logic controllers, configuration elements, CSV files, timers, samplers, etc. Within each test fragment, these elements can be added from 'Test Plan' > Add.

 

 

 

Two test fragments of the shopping module load test

 

A third script, the main script, is added, along with a logic controller called 'Include Controller'. It is necessary to name the .jmx files for each of the modules. For our example, we are using ‘browse.jmx’ for the 'browse' thread, and ‘shop.jmx’ for the ‘shopping’ thread. The modules will run within the script and the actions that are performed can be seen under the 'View Results Tree' tab. Modules can always be added and incorporated in the test in order to split up the user flow and the load test flow.

 

 

The main .jmx scripts

 

 

Each test module has normal testing capabilities, such as logic controller, samplers, etc...

 

 

Run the test and view the results by running both modules

 

Supporting Test Fragments in BlazeMeter

 

To use JMeter test fragments in BlazeMeter, create a new JMeter test by clicking ‘Add JMeter Test'.

 

Add a JMeter test

 

When uploading the file, simply upload the main script and the respective .jmx files:

 

 

Make sure that the main script is selected in ‘JMeter Test Properties’. When BlazeMeter runs the test, it will copy all of the files to the load engine, and the main script will run the ‘browse’ and ‘shop’ files.

 

Additionally, if there is more than one engineer in your team, use BlazeMeter’s ‘subscribe to shared folders’ option, which is a unique feature that allows you access their folders and use their test fragments in your flow. For example, I can subscribe to one colleague’s folder with the ‘shop’ module and another colleague’s folder with the ‘browse’ module, then create the flow using those test fragments when running my script.

 

Final Words

JMeter’s test fragmenting feature allows you to work on large and multifaceted load tests efficiently. With BlazeMeter’s help, you can easily run test fragments and collaborate seamlessly with your colleagues.

 

Want more online training? Check out our performance testing training center for more free webinars and online courses.

 
     
arrow Please enter a URL with http(s)

You might also find these useful:

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