JMeter is a load testing tool to measure the performance of web applications. It is open-source and written in Java.
Key concepts in JMeter
JMeter test script is developed by adding components in the Test Plan pane on the left side. To get a general idea about the components and what can be achieved, let’s go through the various categories of components.
does the actual work in JMeter by sending requests to the server
defines the number of simulated users (also called threads)
Usually, samplers are child elements of the Thread Group.
defines the logic of the test script like conditions and loops
used to view, save, summarize and visualize test results.
defines defaults and variables for later use by samplers
performs additional checks on the sampler results like size, duration, pattern matching etc.
introduce a delay between requests (e.g. simulate user think time)
modify the samplers before they are executed
process the results of the samplers.
Often used to extract data from the response and store it in variables.
The samplers do the actual work of sending requests to the server application under testing.
The most common sampler is HTTP Request.
There are a number of samplers for various protocols like FTP, SMTP, TCP, Mail Reader, LDAP, JMS, BOLT etc.
JDBC Request allows us to send a request to a database (an SQL query).
There are also script samplers where we can write our own code to generate a request or process previous results (more about scripts here).
Logic Controllers are used to define the conditional logic, loops and randomize the order of requests etc.
Following is a short description of all the controllers:
executes child components a given number of times in a loop
runs its children only if the given condition is true
keeps running its children in a loop while the given condition is true
runs one of its children based on a given ‘Switch Value’.
We can use variables to dynamically calculate the ‘Switch Value’.
loops through the values of a set of related variables.
For the above configuration, the ForEach controller will look for inputVar_1 in the first iteration. If the variable is found, the children are executed with the value of inputVar_1 stored in the returnVar variable. Next iteration, the controller will look for inputVar_2 and so on.
Typically, these variables are set earlier by a script after extracting them from a response.
generates an additional sample that measures the overall time taken to perform the nested test elements.
has no logic, it is just used to group components together. You can think of it as a filesystem folder.
Only Once Controller
executed only once i.e. during the first iteration of any looping parent controller.
If the parent looping controller restarts, Only Once Controller will also be reset.
runs one of the child components alternately during each loop iteration
acts similarly to Interleave Controller, except that it picks one of the child components at random for each pass instead of going in order.
Random Order Controller
executes each child element once but in random order.
You can think of it as a Simple Controller with the random ordering of child elements.
controls how often child elements should be executed in terms of a number of times or percentage.
It is badly named, doesn’t control throughput.
controls how longs its children will run. Keeps on running its children until a given duration.
allows reusing a Test fragment
allows including an external JMX file
Critical Section Controller
ensures that children are executed by only one thread at a time.
It takes lock only within one JVM, so won’t work with distributed testing.
Listeners allow us to view, save, summarize and visualize results.
‘View Results Tree’ is the most common way of viewing the results, particularly during test script development. It lists all the requests made along with complete request and response data.
Another useful visualizer is ‘View Results in Table’. It creates a row for every request (sampler). The output can be exported to CSV file which is much easier to analyze and summarize than the results of some of the other listeners.