It is always beneficial to understand the basic required features of any Tool before start using it. So, in this article we are going to discuss about some very important but basic Jmeter Features.
If you are new and just have started learning Jmeter, please do not jump directly into complex fancy stuff. You will get confused and suddenly Jmeter will start looking like a Big scary dragon (And you are not Khaleesi, for sure).
Prerequisite Articles :
If you are new to Jmeter, Read below mentioned articles before going any further.
I will be showcasing the latest version of Jmeter (V3.0 released on May 17th, 2016). Now, let’s start a tour of Jmeter 3.0
Below displayed screen will appear when you open Jmeter 3.0
To get started with preparing your first script in Jmeter, You will need to understand functioning of below mentioned Jmeter Features :
1) Test Plan
2) Thread Group
3) HTTP(S) Test Script Recorder
4) Recording Controller
5) HTTP Request Defaults
6) HTTP Cookie Manager
7) User Defined Variables
Test Plan in Jmeter
A Test Plan in your Jmeter screen is a shelter where you can keep all necessary configurations to execute the script, Test Steps and elements to record the results. There are so many configuration and Test elements you can add in a Test Plan, but here we will discuss about only necessary ones to run a basic Jmeter script.
To add any element or corresponding settings you will need to Right Click on Test Plan and the First option you will see as “Add”. As displayed in above image you will see these options can be added as part of the Test Plan :
– Threads(Users) : Thread Group is added to the Test Plan from this option which acts as starting point of any Jmeter Performance script.
– Test Fragment : A special type of controller which stays at the Thread Group Level. It won’t be part of your execution unless referenced by either Module Controller or Include Controller.
Urghh !!! Right ? OK, let me explain in most simplest manner. Using Test Fragments, multiple modules of your complex Test script can be configured in a single Test Plan and can be run simultaneously as part of the single Load test run.
How ?? will see later. Let’s focus on basic configuration first.
– Config Element : All the required configuration to Run a Test script is added from this option. For example : Reading Test Data value from CSV file, Cookie Manager, Cache Manager, Storing user defined variables, HTTP & FTP request defaults and many more.
– Timers : By default Jmeter does execution without any pause. Timers can be added to cause delay of defined amount of time before executing each sampler.
– Pre Processors : Used to execute some actions prior to a Sampler Request sent to the server.
– Post Processors : Used to execute some actions after the Sampler Request is executed and sent to the server.
– Assertions : All Green and No Errors in the response? Awesome, your Jmeter script has been executed successfully. Wait, Did you look into the response for confirmation? Don’t rely on error rate or green color for the success of your test. It is possible that you might not get the expected result but Jmeter will show that your test is passed.
You can automate this process by adding Assertions. Every time you will run the script, “Assertions” will find the pattern to match in the response and based on that success / failure will be decided.
– Listeners : It is used to showcase the response fetched from the server for each execution.
A Thread Group in Jmeter is the starting point of any Test Plan. It consist set of Threads(Users) to be used in execution of same scenario. Apart from “Number Of Threads” you can also mention “Ramp-Up period in seconds” and number of iterations. You can also set a scheduler for the execution by providing “Duration in seconds”, “Start Time” and “End Time”.
In simple words, a Thread Group is used for storing all necessary configuration to Run Your Jmeter Performance Script.
How to Add Thread Group under Test Plan ?
Adding Thread Group is the first step of building your Jmeter script. To add Thread Group : Right Click on Test Plan > Add > Threads(Users) > Thread Group.
Once the Thread Group is added, your screen will look like this :
HTTP(S) Test Script Recorder
HTTP(S) Test Script Recorder is used intercept and capture your actions while you are functionally navigating on the browser. Note that, Jmeter depends on it’s proxy server to record the actions performed on the browser. So before starting the recording change browser’s proxy setting to match with Jmeter’s.
Once you start the recording and perform actions on the browser, Jmeter will start creating Test sample request and store them directly under Thread Group.
How to Add HTTP(S) Test Script Recorder ?
Right Click on WorkBench > Add > Non-Test Elements > HTTP(S) Test Script Recorder.
Now, let’s understand some required features of Script Recorder.
– Port : This field contains the port value that Jmeter proxy will use to listen. Be default it will have value “8888”, but it can be changed.
– Target Controller : To define the place where you want Jmeter to store all the recorded requests. By default it has the value of “Recording Controller”, but you can change it to either “Thread Group” or any other controller.
– Grouping : This option is used to group the recorded requests for each action (click). By default it will have value as “Do not group samplers”, where Jmeter stores all the requests subsequently without any grouping.
– Capture HTTP Headers : Yes.
– Patterns to Include / Exclude : Provided regular expression patterns will be checked against the URL being recorded. If the match found, Jmeter will take action to either include or exclude that request.
– Start / Stop Button : Used to initiate / stop the proxy server.
The Recording Controller is a container in which HTTP Test Script Recorder stores all the samplers. Note that, it does not play any role in execution.
How to Add Recording Controller ?
Right Click on Thread Group under Test Plan > Add > Logic Controller > Recording Controller.
Before you start feeling this tutorial as a never ending Jmeter Voyage, Let’s take a break !!
I have not failed. I’ve just found out 10,000 ways that won’t work.
– A Jmeter User
To understand remaining Jmeter Features from the list, Click Here.