Welcome to this post of How to create JMeter Performance Test. We will try to explain basic terminology used in JMeter and create a sample JMeter script. Before going to detailed post here is the overview of this article.
How to create JMeter Performance Test – Overview
- What is JMeter
- Protocols supported by JMeter
- Basic Terminology of a JMeter Test
- Creating a basic JMeter Script
- Running our JMeter Test
- Analyzing our test result
What is JMeter
JMeter is an open source tool to test the performance of various functionality of an application under test. It is purely developed using Java which makes it lightweight and reliable performance testing tool. Initially, It was developed to test the web apps but it has been extended to test various protocols.
Protocols supported by JMeter
JMeter is currently supporting multiple protocols due to which it is widely used performance testing tool. Protocol is a set of rules that allows electronic devices to communicate. Some important protocols that JMeter supports are following :
- Web – HTTP/HTTPS
- Web Services – SOAP/REST
- FTP – File Transfer Protocol
- Database Protocol Using JDBC
- Message Oriented Middle ware – JMS
- Mail – SMTP
- Native Commands or Shell Scripts
- Java Objects
Basic terminology of a JMeter Test
While designing a performance test scenario in JMeter, we come across many terms. These components controls the behavior of the test. It is very important to have understanding of the functionality of each parts of Test.
- Test Plan – A test plan is a series of defined test steps that JMeter will execute while running. It contains Thread Groups, Request Sampleras, Config Elements, Logical Controllers, Timers etc. A test plan holds multiple elements of a test.
- Thread Group – Thread Group provides the ability to configure the number of threads (virtual user) which will iterate over the defined elements of a test plan. A thread execute the test plan in its entirety and completely independent of each other. We will see more while creating a test plan.
- Samplers – Samplers tells JMeter to send a request and wait for the response from the target system.
- Listeners – Listeners provides the information about a test which JMeter gathers. It shows you how is your test progressing.
There are many components of a JMeter Test depending upon the complexity of a scenario.
Creating a basic JMeter Script
We have a basic understanding of a JMeter Test. Let us create a simple JMeter Test. To create a JMeter Test, I am assuming you have installed JMeter and JMeter Application is running. It may look like this.
In the left side we have solution explorer where we will be adding and removing various elements of a test plan. Let us add some elements to our test
How to create JMeter Performance Test
- The first step is to add a Thread Group. A test may contain multiple thread groups depending on the scenario.
- Once a thread is added we need some samplers which are to be executed by our threads
- Right click on Test Plan > Add > Samplers > HTTP Request. HTTP Request Sampler holds the information of the request and send request to the target system. You will have to fill the fields like Server Name or IP. For simplicity I will fill google.com in Server Name or IP field.
- We also need Listeners which logs the information of the requests sent by JMeter. To add Listener, Right Click on Thread Group > Add > Listeners > View Result Tree, View Result Tree gives us all important information about the request and response.
Running a JMeter Test
Running a JMeter test is very simple. You can run a JMeter Test using GUI or Non-GUI. In Performance Testing when we need to send thousands of request, We use Non-GUI mode where a test is executed using Command Prompt. If we are running a test while script preparation, We use GUI mode. In GUI, we have a button in shortcut bar i.e START and STOP button. Once you click Start, the test starts. To run a test in NON-GUI Mode, We have a guide on How to Run a JMeter Test in Non-GUi Mode
Analyzing JMeter Test
We often need to know about the request that was sent by JMeter. We can get the result in the Listener Section. In the above image you can see that the request sent by JMeter is passed. It means Google responded back with the expected result.
When we go to click on HTTP request, you will get more information about the response headers and content of the response. It helps us while preparing a load test script where you can see the response given by target system. In case the request failed, you will come to know about the reason returned by the target system.
Now, you know basic elements about JMeter and how to create a basic performance test in JMeter.