JMeter, Performance Testing, Testing, Tools

How to create Custom Templates in JMeter?

In this blog post, we are going to see about how to create custom templates in JMeter. Earlier post explains about JMeter Templates, its purpose and how to add JMeter templates to your Test Plan. The goal of this article is to teach you how to customize the JMeter templates in JMeter.

Suppose you are working on a banking application where you perform following transactions repeatedly:

Scenario 1:

  • Login
  • Check Balance
  • Logout

Scenario 2:

  • Login
  • Apply Loan
  • Logout

Scenario n:

  • Login
  • Pay Bill
  • Logout

In this case, you might need to create many test plans in same fashion i.e. adding a Thread Group, adding HTTP Cookie Manager, adding HTTP Authorization Manager, adding three Loop Controllers, and two Listeners.

To expedite the process of creating items for your thread group, it is ideal to create a custom template. By one click you will be able to add the thread group with all your desired elements.

Steps to create custom templates in JMeter?

Follow the below steps sequentially to create custom templates:

  • Go to JMETER_HOME\bin\templates folder.
  • Open templates.xml in your favorite editor. I use Notepad++ or jEdit.
  • Copy below code and paste it in the templates.xml just before </template> tag.
 <template isTestPlan="true">
        <name>My Test Plan</name>
        <fileName>/bin/templates/my-test-plan.jmx</fileName>
        <description><![CDATA[
        <h1>This is my test plan</h1>
        <h2>My reference link</h2>
            <ul>
                <li><a href="http://myurl" >http://myurl</a></li>
            </ul>      
        ]]></description>

  • You can change the bold text in the above code as per your need.
  • Now launch JMeter 2.11 and design your test plan that you need to convert it to a template. Below is the sample test plan that I have created for demonstration purpose.
JMeter Template
JMeter Template
  • Save your created test plan as my-test-plan.jmx in the following JMETER_HOME\>/bin/templates/
  • Check whether the name of your JMeter template and its path is same as you mentioned in the templates.xml file.
  • Click on Templates icon, and then click on Reload Templates button. You could see your created template gets listed out as shown below.
  • Click on Create button to add it your test plan.
Custom Template
Custom Template

Subscribe for free newsletter

Once a week we send a digest with the most popular articles.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

New Year. New Hope. Learn TruWeb. 78% OFF for Limited Time of my Udemy course..BUY NOW