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:
- Check Balance
- Apply Loan
- Pay Bill
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.
- 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.
- #3 – LoadSter, Google Chrome, and Sonarwhal – QAInsights Podcast - April 25, 2018
- #2 QAInsights Podcast – 220.127.116.11 and many more - April 9, 2018
- QAInsights Podcasts – First Episode - March 30, 2018
- Rajini Makkal Mandram Vs Makkal Neethi Maiyam – a tech comparison - March 5, 2018
- Do not blame it on server! - February 26, 2018