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.
- Unboxing HPE LoadRunner 12.55 - August 20, 2017
- Measure Client-side Performance using Lighthouse - August 10, 2017
- Perf Calculator – free iOS app for performance testers - July 16, 2017
- How to performance test AngularJS or ReactJS applications? - June 25, 2017
- How to run Apache JMeter tests with Visual Studio Team Services? - June 6, 2017