Table of contents
1.
Introduction
2.
About JMeter Test Plan
3.
JMeter Test Plan Elements
4.
Thread Group
5.
Controllers
5.1.
Samplers
5.2.
Logic Controllers
6.
Test Fragments
7.
Listeners
8.
Timers
9.
Assertions
10.
Configuration Elements
11.
Pre-processor Elements
12.
Post-processor Elements
13.
Order of Execution of Test Elements
14.
Frequently Asked Questions
14.1.
In JMeter, how many threads can be executed at once?
14.2.
In JMeter, what is thread lifetime?
14.3.
JMeter employs which programming language?
14.4.
In JMeter, what are non-test elements?
14.5.
What exactly is a simple configuration element in JMeter?
15.
Conclusion
Last Updated: Mar 27, 2024

What are JMeter Test Plan Elements?

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Welcome Ninjas!

This article brings you a detailed discussion of JMeter Test Plan elements. We hope you are as excited to know about JMeter Test Plan elements as we are to help you learn about them.

JMeter Test Plan elements

So without wasting any more time, let us start our discussion on the topic. We will begin with a brief intro to JMeter test Plan and then move forward with the elements.

About JMeter Test Plan

A test plan is your JMeter script for running tests. Components like the Thread groups, logic controllers, controllers, listeners, timers, assertions, and configuration elements comprise a test plan.

JMeter logo

A test plan includes all of the steps required to run the script. Everything in a test plan is executed in a top-to-bottom sequence or according to the test plan's defined sequence. The diagram below depicts the directory level of a test plan.

Test Plan directory

Points to note on a Test Plan - 

  • Before running the entire test plan, the test plan is saved.
     
  • JMeter files or test plans are saved in ‘.JMX’ extension. JMX is an open test format that allows the test plan to be run in a text editor.
     
  • Parts of the test plan can also be saved as a different selection. For example, if you want to save an HTTP request sampler with a listener, you can save it as a test fragment and use it in other test scenarios.
Test Plan Panel

The above image shows the JMeter Window.

JMeter Test Plan Elements

A JMeter Test Plan is made up of the test elements listed below. A Test Plan must include at least one Thread Group. Within each Thread Group, we can mix and match one or more of the following elements: the Sampler, Logic Controller, Listener, Configuration Element, and Timer. Each Sampler can have one or more Pre-processor elements preceding it, followed by a Post-processor element and an Assertion element. Let us explore each of these elements in greater depth.

Before the detailed discussion, let's see a flowchart to help you understand the elements.

Elements of JMeter Test plan

Below given are some major elements of JMeter:

  • Test Plan
  • Thread Group
  • Controllers
  • Listeners
  • Timers
  • Configuration Elements
  • Pre-Processor Elements
  • Post-Processor Elements
Elements of JMeter

The above image shows what all Jmeter Test Plan elements can be added to the test plan.

Thread Group

Thread Group elements serve as the starting point for your test strategy. As the name implies, the thread group elements control the number of threads used by JMeter during the test. The Thread Group also allows us to control the following.

  • Configuring the number of threads
     
  • To set ramp-up time. Ramp-up is the period of time Apache JMeterTM will require to add all test users (threads) to a test operation. Or, to put it another way, how long it will take JMeter to begin running each thread.
     
  • To set the number of test iterations to run.
     

The Thread Group Panel contains the following elements:

  • Action to be taken in the event of a Sampler error: If an error occurs during test execution, you may allow the test to either
    1. Continue to the next test element.
    2. Stop Thread to terminate the current Thread.
    3. Stop Test entirely if you want to inspect the error before it continues to run.
     
  • The Number of threads: It simulates the total number of connections to your server application.
  • Ramp-Up Period: It specifies how long JMeter will take to start all threads.
  • Loop Count: It specifies how many times the test should be run.
  • Scheduler checkbox: When you select the Scheduler checkbox, the Scheduler Configuration section can be noticed at the bottom of the control panel.
  • Scheduler Configuration: You can specify when the test should begin and end.
     

Let us see what the Thread Group Panel looks like in the image below:

Thread Group Panel

Controllers

There are two types of Controllers in JMeter: Samplers and Logic Controllers.

Samplers

JMeter can send specific types of requests to a server using samplers. They simulate a user request for a page from the target server. For example, if you need to execute a POST, GET, or DELETE on an HTTP service, you can add an HTTP Request sampler.

Examples of some useful samplers are −

  • HTTP Request
  • JDBC Request
  • Java Request
  • FTP Request
  • RPC Requests
  • SOAP/XML Request
     

For example:

HTTP Request Sampler

Logic Controllers

Logic Controllers allow you to control the order in which Samplers in a Thread are processed. Logic controllers can reorder requests coming from any of their child elements. 

A few examples of logic controllers are:

  • ForEach Controller
  • While Controller
  • Loop Controller
  • Run Time Controller
  • IF Controller
  • Interleave Controller
  • Throughput Controller
  • Run Once Controller
  • Random Controller
  • Switch Controller
  • Transaction Controller
  • Once only Controller
  • Recording Controller
     

Let’s see the panel for while controller:

While Controller

Test Fragments

The Test Fragment element is a type of controller that exists on the same level of the Test Plan tree as the Thread Group element. It differs from a Thread Group in the manner that it is not executed unless referred to by a Module Controller or an Include_Controller.

 The Test fragment panel in JMeter looks like this:

Test Fragment

Listeners

Listeners allow you to view Sampler results in log files as tables, graphs, trees, or plain text. They show the data collected by JMeter about the test cases as the Sampler component of JMeter is executed.

Listeners

Listeners can be added to the test at any point, including directly under the test plan. They will only collect data from elements at or below their level.

The list below includes all of the Listeners that JMeter offers:

  • Sample Result Save Configuration
  • Graph Full Results
  • Aggregate Report
  • Mailer Visualizer
  • BeanShell Listener
  • Summary Report
  • View Results in Table
  • Simple Data Writer
  • Monitor Results
  • Distribution Graph (alpha)
  • Graph Results
  • Spline Visualizer
  • Assertion Results
  • View Results Tree
  • Aggregate Graph
     

Example of a Listener called Summary Report:

Summary Report

Timers

Assertions allow you to include a validation test on the response to a Sampler-based request. You can use assertions to demonstrate that your application is returning correct data. When an assertion fails, JMeter highlights it.

Below given is the list of Timers in JMeter:

  • Constant Timer
  • Gaussian Random Timer
  • Uniform Random Timer
  • Constant Throughput Timer
  • Synchronizing Timer
  • JSR223 Timer
  • BeanShell Timer
  • BSF Timer
  • Poisson Random Timer
     

An example of a Timer called JSR223 Timer:

JSR223 Timer

Assertions

In JMeter, the assertion is used to validate the response to the request you sent to the server. At run time, the assertion is a process in which you compare the expected result to the actual result of the request. If you need to apply assertion to a specific Sampler, make it a child of that Sampler.

Assertions

Below given is the list of all the assertions JMeter provides −

  • Compare Assertion
  • Beanshell Assertion
  • BSF Assertion
  • JSR223 Assertion
  • BeanShell Assertion
  • MD5Hex Assertion
  • HTML Assertion
  • XPath Assertion
  • Response Assertion
  • Duration Assertion
  • Size Assertion
  • XML Assertion
  • XML Schema Assertion

Configuration Elements

Configuration Elements allow you to define defaults and variables for Samplers to use. They are used to add or change Sampler requests.

They are implemented at the start of the scope in which they are located, before any Samplers in the same scope. As a result, a Configuration Element can only be accessed from within the branch in which it is placed.

Below given is the list:

  • Counter
  • CSV Data Set Config
  • FTP Request Defaults
  • HTTP Authorization Manager
  • HTTP Cache Manager
  • HTTP Cookie Manager
  • HTTP Proxy Server
  • HTTP Request Defaults
  • HTTP Header Manager
  • Java Request Defaults
  • Keystore Configuration
  • JDBC Connection Configuration
  • Login Config Element
  • LDAP Request Defaults
  • LDAP Extended Request Defaults
  • TCP Sampler Config
  • User Defined Variables
  • Simple Config Element
  • Random Variable
     

Below is an example of JDBC Configuration panel:

JDBC Configuration Panel

Pre-processor Elements

A pre-processor element is something that runs before the execution of a sampler. Pre-Processor elements are frequently used to modify a Sample Request's settings just before it executes.

All of the pre-processor elements provided by JMeter are listed below.

  • HTTP URL Re-writing Modifier
  • HTML Link Parser
  • HTTP User Parameter Modifier
  • User Parameters
  • RegEx User Parameters
  • BeanShell PreProcessor
  • BSF PreProcessor
  • JDBC PreProcessor
  • JSR223 PreProcessor
     

Below given is an example of a Pre-processor called the JSR223 Pre-Processor:

JSR223 Pre-Processor panel

Post-processor Elements

Post-Processors are actions that occur after your sampler starts running. You can use them to perform actions on your response or to extract values from the response and save them in a variable for later use.

  • Regular Expression Extractor
  • XPath Extractor
  • Result Status Action Handler
  • JSR223 PostProcessor
  • JDBC PostProcessor
  • BSF PostProcessor
  • CSS/JQuery Extractor
  • BeanShell PostProcessor
  • Debug PostProcessor
     

Below given is an example of a Post-processor called the XPath Extractor:

XPath Extractor Panel

Order of Execution of Test Elements

The execution order of Test Plan Elements is as follows:

  1. Configuration elements
  2. Pre-Processors
  3. Timers
  4. Sampler
  5. Post-Processors (unless SampleResult is null)
  6. Assertions (unless SampleResult is null)
  7. Listeners (unless SampleResult is null)

Frequently Asked Questions

In JMeter, how many threads can be executed at once?

JMeter allows you to run multiple processes in the same box, and it generates up to 200 threads per JMeter instance. If you require more, we recommend running multiple JMeter instances. With some tweaking, a modern machine can easily generate 500 to 1000 threads.

In JMeter, what is thread lifetime?

Each thread will begin 10 (100/10) seconds after the previous one. With 30 threads and a ramp-up time of 120 seconds, each subsequent thread will be delayed by 4 seconds.

JMeter employs which programming language?

JMeter uses the Groovy language as a scripting language. Groovy has proven to be a powerful yet lightweight language in terms of performance when it comes to improving JMeter's functionality.

In JMeter, what are non-test elements?

You can capture network traffic in JMeter by adding a Non-Test element to your test plan. Right-click on Test Plan > Add > Non-Test Elements > HTTP(S) Test Script Recorder and select HTTP(S) Test Script Recorder. JMeter will now have the ability to record. Understand the business flow and have your input data ready before you begin recording.

What exactly is a simple configuration element in JMeter?

The 'Simple Config Element' in JMeter adds or overrides arbitrary values in samplers. You can customize both the value's name and the value itself.

Conclusion

This article brought you a detailed discussion of the various JMeter Test Plan elements and their sub-components and types. We hope you now understand what a JMeter Test Plan is and what the JMeter Test Plan Elements are.

For more information on JMeter, Refer to our other articles-

Please refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. And also, enroll in our courses and refer to the mock test and problems available. Have a look at the interview experiences and interview bundle for placement preparations.

Keep learning, and Keep Growing!

Live masterclass