Close

February 11, 2014

How to create Custom Templates in JMeter?

JMeter Template

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

About NaveenKumar Namachivayam

Hi there! is a passionate and experienced Performance Test Analyst based in Chicago, USA with skill sets in Manual Testing, Test Automation, Performance Testing, and Test Estimation. He loves to learn and experiment new trends and models in Software Testing. Please stop by at his personal blogs: Excel Blog, DealsBrook, NaveenKumarN.in, and Affiliate Insights blog and Software Testing Memes.

Leave a Reply

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