Table of content

JMeter Templates

JMeter Templates are skeleton scripts that you can reuse to get started with a project.

You can either use existing templates or create your own. You can also create snippets of code that you can insert into your script with templates.

  • To see the Existing templates in the JMeter,
  • Click on the Template icon in the JMeter Toolbar.
  • Once you click on the Template icon a new window will open, which contains a drop-down list of existing templates in JMeter.
    template-icon-jmeter-toolbar
  • Each existing template has a description and useful links to understand each and every element in the created test plan.
  • Select the one you want, click on Create and the framework will be automatically be created, Just you need to edit some variables and can run your own script.
  • Unlike other Templates, the BeanShell Sampler does not override the Test Plan in Jmeter script. It is added as a sampler right into the script.
Creating Own Template in JMeter :
  • Open the JMeter and then add a Thread group and an HTTP Request to the Thread Group.
  • And also add view Result Tree listener to the thread group
  • If you want to add server and path you can add, I am adding www.google.comas a server name and root path as /.
    http-request-for-templates-jmeter
  • Now I am going to save this test plan as a Template, which can be used in the future as a reference.
  • We need to save this test plan under Template as a .jmx file.
    creating-own-template-jmeter
  • Go to the JMeter folder where you have installed and go to the template folder under the bin, you will find the newly created template Owntemplate.jmx.
    new-template-under-template-folder-jmeter
  • Next, we need to ad OwnTemplate.jmx file inside the template.xml file.
    template-xml-file-jmeter
  • Open the Template.xml file in the notepad, there you will find multiple templates which are already present.
    template-in-notepad-jmeter
  • Each template described by 4 tags:
    <template> - root tag that describe, will this template be create new test plan (isTestPlan="true"), or can be merged to existed (isTestPlan="false"). 
    <name> - template name
    <fileName> - path to .jmx file
    <description> - template description, presented in HTML text. ​
  • Copy one Simple tag and paste it on the same page and enter the details of your template.
  • In the below code I have changed the name to OwnTeplate and file I have given the complete path of the OwnTemplate.jmx file.
    created-template-jmeter
    <template isTestPlan="true">
            <name>OwnTemplate</name>
            <fileName>D:Jmeter_Projectapache-jmeter-5.2.1in	emplatesOwnTemplate.jmx</fileName>
            <description><![CDATA[
            <h1>Test plan from Building a Web Test Plan section in user's manual</h1>
            <h2>Useful link</h2>
                <ul>
                    <li><a href="http://jmeter.apache.org/usermanual/build-web-test-plan.html" >http://jmeter.apache.org/usermanual/build-web-test-plan.html</a></li>
                </ul>       
            ]]></description>
        </template>​


  • Now save and exit the file and after that restart the JMeter.
  • Once the JMeter has opened, click on the Template icon, you will find our newly created template OwnTemplate.
    reflecting-created-templated-in-drop-down-list-jmeter
  • Click on the Create, then your new template will be created.
    create-own-template-jmeter
  • Once you click on Create, you will find the below page.
    own-template-page-created-a-test-plan-jmeter
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions