info@pragmatictesters.com +94 11 253 8512

INTRODUCTION

Building a test plan (JMX) to simulate real user behaviours is one of the important and major  tasks of JMeter performance test engineers. There are number of options available for building JMeter Test Plan.

Getting familiar with few available options will be useful when a options is not working. You can choose the right option or the mixture of options to build correct test plan(s) and to improve the productivity. 

  1. Building a test plan from the scratch 
  2. Using HTTP(S) Test Script Recorder 
  3. Create test plans with Templates 
  4. Building test plans with Test Fragments 
  5. Record test script with Blazemeter Extension 
  6. Create test plans from cURL commands 
  7. Build test plans with OctoPerf 
  8. Creating test plans from log files 
  9. Converting HAR files to JMeter test plans 
  10. Creating test plans from Postman

Building test plan from the scratch

We can build JMeter test plans by adding the required JMeter components manually. This method could be used for websites, web services and simple web applications.

We will have to use this option when you want to build test plans for other applications/ server/ protocol types such as LDAP, FTP Databases via JDBC, TCP with custom configurations where test script recording is not possible.

We should have good understanding of available components and plugins to build test plans simulating real-world scenarios.

You can move into recording test scripts when you are comfortable with the basics as you ALWAYS have to modify the recorded test plans.

Creating Test Plans with HTTP(s) Test Script Recorder 

You can record the user actions and create a JMeter test plan with HTTP(S) Test Script Recorder. You should get familer with this option for building test plans for web applications. Recording test scripts will save a lot of time in building the test plans if you configure the HTTP(s) Test Script Recorder properly. 

In the following video, I have explained the process to you.

Using JMeter templates

JMeter comes with pre-configured test plans with basic components for various applications, servers and protocols and snippet for merging with the test plans. These templates reside in bin/templates directory.

Any new template can be registered through templates.xml file. The Document Type Definition (DTD) is defined in templates.dtd file. You can save test plans into the templates directory and register them in templates.xml file.

The templates can be added using File → Templates menu or Templates icon in the toolbar.

Following window will be opened to select a test plan or snippet.

Create or Merge button will appear in the window based on the selected template. Click on the button to add the selected template.

You can customize the existing templates or create your own templates and register with template.xml.

Using Blazemeter Chrome extension

The Chrome extension records all of the HTTP/S requests that your browser sends, creates a JMeter script.

Install the Blazemeter Chrome extension

  • Open the extension
  • Set the test plan name and click on Start Recording  button 
  • Browse through the web application/site
  • Click on Stop Recording button when test flow is completed 

  • Click on Export to JMeter button
  • Save the test plan into the test plan directory
  • Open the test plan using JMeter GUI

It is very easy to install the extension, record test scenarios.

Following should be noted:

  1. URL patterns to be excluded is not available. Hence all .css, .js requests are recorded. You will have to delete them manually.
  2. Constant timer is added to HTTP Request. You will have to change the value or use a different timer such as Random Gaussian timer to simulate the varied think time of actual users 
  3. Base URL is set in the User Defined Variables configuration element. The variable is used in HTTP Request samplers. Base URL is hardcoded in the HTTP Request Manager configuration element within the HTTP Request samplers. You can use Find and Replace feature to replace the URL with a variable.

Creating a Test Plan with cURL commands

You can easily convert the cURL commads to JMeter HTTP Requests using cURL import utility. The process is documented in the Apache JMeter official site.  I have used the feature to build the REST API test plans.

cURL commands can be copied from Google Chrome developer tool. Select the Network Tab -> Fetch/XHR. Start performing the user actions and select the request you want to convert. Right click on the request and select copy-> Copy as cURL. cURL command is copied into the clipboard.

Then paste the cURL command into the cURL import utility and press the Create Test Plan button.

Building  a Test Plan with OctoPerf

OctoPerf is a commercial Saas and on Premise platform. You can use OctoPerf to upload Chrome/Firefox/Fiddler  HAR file and export as a JMeter test plan.

HAR denotes HTTP Archive file. It is a JSON-formatted file that contains a trace of your actions with the web browser. Chrome and Firefox have the ability to record network activity and export the trace as a HAR file or copy its contents to the clipboard.

  • Login to OctoPerf. You can use Google or LinkedIn accounts
  • Add a new project by providing project name and description
  • Select the appropriate option and upload the file

Your test plan is created with a default configuration

Test plan can be improved using a wide range of features

  • Correlation rules: –  Correlation Rule automates the time-consuming, error-prone and painful task of:
  1. Creating variable extractions,
  2. And replacing dynamic values with variables in requests.
  • Variables: – The variable page lets you configure, in one place, predefined variables. Constants, Random and from CSV files are supported.
  • Session variables for various frameworks are predefined. They can be easily added and used in the HTTP Samplers.

Once the test plan is updated with real workload scenarios the Test Plan can be exported.

  • Select Export VU option from the right menu.

  • Select Download JMX option and save the test plan into test plan folder.

  • Save the test plan into the local directory
  • Open the test plan in JMeter IDE

Using Access Log Files

JMeter sampler, Access Log Sampler provides an easy way to simulate production traffic using web servers’ access logs. Access Log Sampler can read access logs and generate HTTP requests. Test plan building process becomes very easy when you choose this approach.

Web Server should be configured to log the requests.

Please refer to Access Log Sampler step by step tutorial from the official site for more details.

  • Start creating a new test plan
  • Add a Thread Group
  • Add Access Log Sampler
  • Configure the Sample by setting protocol, server and port

  • Select the log file
  • Add the listeners
  • Save the test plan and run the test

The test will simulate the production workload experienced by the server.

Converting HAR files with Blazemeter 

You can record the user actions and export the action to a HAR file. The HAR file can be converted into a JMeter script (JMX) with a HAR to JMX using Blazemeter JMX Converter.

Here is one method to save the requests into a HAR file. Open Google Chrome developer tool. Select the network tab. Recording is enabled by default. Start performing the user action in the browser and see the acttions are getting recorded. Right click on a request and select Save all as HAR with conetent from the menu to save the requests to a HAR file. Now you can conver the HAR file to a JMX using Blazemeter JMX Converter.

Building Test Plans with Test Fragments

You can save the frequently used components or group of components as test fragments and easily merge them with the test plans later. User login, removing outliers from test results, token management, extracting session variables configurations are similar across the test plans.

Select the component or a group of components once they are configured. Right-click and select the Save as Test Fragment option.

Usually, the test fragments are saved into a different folder. The test fragments can be merged with existing test plans by selecting Merge option from the context menu to File –> Merge.

The test fragments can be integrated as a template and can be merged from the template menu too.

Building Test Plans from Postman

You can send the existing postman scripts through JMeter HTTP(s) Test Script Recorder (proxy) and convert them into a JMeter Test Plan.

I have explained the process in this short video.

We have discussed 10 different ways to build a JMeter test plan. We have removed creating test plans using BadBoy software as the software is not active since 2011. We have excluded different methods available for converting Selenium scripts into JMeter as the solutions were not statble.

Now you have number of methods to create JMeter test plans. Select the best method(s) suitable for your project. Enjoy buiding JMeter test plans !

It’s posiible to convert the SoapUI scripts or any other HTTP(s) traffic to a JMeter Test plan by sending the requests through the JMeter HTTP(s) Test Script Recorder.


About Pragmatic

Pragmatic Test Labs is a software testing company based in Sri Lanka. We provide one-to-one JMeter training, Performance Testing services and JMeter consultation on-demand.

We have recently partnered with Redline13 to provide efficiant and cost-effective distributed testing solutions to the clients.

Please contact janesh@pragmatictesters.com for details.

Author: Janesh Kodikara

Performance Tester | JMeter Trainer | Software Testing Service Provider

Your Turn To Talk

Leave a reply:

Your email address will not be published.