JMeter Tutorial 3: Elements of JMeter

Elements of Apache JMeter, Test Plan, Thread Group, Controllers, Listeners, Timers, Assertions, Configuration Elements, Pre-Processor Elements, Post-Processor Elements and Execution order of Test Elements.

Start / Launch JMeter Tool, Select Test Plan, Add Thread Group, Add Processes, Add Samplers, Add Logic Controllers, Add Listners, Add Timers, Add Assertions, and Save the Test Plan.

Create JMeter Web Test Plan, JMeter Database Test Plan, JMS Test Plan, JMeter FTP Test Plan and JMeter Web Services Test Plan, and conduct Web Page Performance Testing, Database Server Performance Testing and Web Services Performance Testing.

Conduct all types of Performance Testing like, Load Testing, Stress Testing, Spike Testing, Endurance Testing, Data Volume Testing using Apache JMeter Tool.

Elements of JMeter Test Plan

> Different parts or components of JMeter are called JMeter Elements they co-relate with each other but designed for different-different purposes.

> Before start working on Jmeter Tool , it is important to know all components or Elements of Jmeter with full detail description.

Common Elements in JMeter are,

1.0) Test Plan
1.1) Thread Group
1.2) Controllers (Samplers, Logical Controllers)
1.3) Listeners
1.4) Timers
1.5) Assertions
1.6) Configuration Elements
1.7) Pre-Processor Elements
1.8) Post-Processor Elements

Execution order of Test Elements

1.0) Test Plan:

> A test plan is the top level element of JMeter, explains sequence of steps execute at run time. A test plan made up of Thread Groups, Sampler, logic controller/s, listener/s, timer/s, assertions/, and configuration elements. Each Sampler can be preceded by one or more Pre-processor element, followed by Post-processor element, and/or Assertion element.

> Test Plan saves in Java Management Extensions (JMX) format.

1.1) Thread Group

> A Thread Group is a set of threads executing the same scenario. It is the base element for every JMeter test plan.

> There are multiple thread groups available which can be configured to simulate how the users interact with the application, how the load is maintained and over what period of time.

Thread Group options:

i) Number Of Threads: It represents the total number of virtual users performing the test script execution.

ii Ramp-Up Period (in seconds): It tells JMeter how long to take to reach the full number of threads. For example, if you have 100 users with a ramp-up period of 50 seconds, JMeter will take 50 seconds to get all 100 threads running, adding 2 threads per second.

iii) Loop Count: It is the number of executions for the script. For example, if the loop count is 2 and number of threads is 100 then the script will run 200 times. If the loop count is set “forever” then new threads will keep starting until the tests are stopped.

iv) Delay Thread Creation Until Needed: If this option is checked, the ramp-up delay and startup delay are performed before the thread data is created. If not checked, all the data required for the threads is created before starting the execution of a test.

v) Scheduler: This schedules the tests. You can set custom duration and startup delay to create the threads in this section.

1.2) Controllers

> JMeter has two types of Controllers: Samplers and Logical Controllers. These drive the processing of a test.Samplers tell JMeter to send requests to a server.

1.2.1) Samplers

> Samplers tell JMeter to send requests to a server and wait for a response. They are processed in the order they appear in the tree. Controllers can be used to modify the number of repetitions of a sampler.

JMeter samplers include:

FTP Request
HTTP Request (can be used for SOAP or REST Webservice also)
JDBC Request
Java object request
JMS request
JUnit Test request
LDAP Request
Mail request
OS Process request
TCP request

1.2.2) Logical Controllers

> Logic Controllers let you customize the logic that JMeter uses to decide when to send requests. Logic Controllers can change the order of requests coming from their child elements. They can modify the requests themselves, cause JMeter to repeat requests, etc.

Logic Controllers of JMeter provide,

Runtime Controller
Transaction Controller
Recording Controller
Simple Controller
While Controller
Switch Controller
ForEach Controller
Module Controller
Include Controller
Loop Controller
Once Only Controller
Interleave Controller
Random Controller
Random Order Controller
Throughput Controller

1.2.3) Test Fragments

> The Test Fragment element is a special type of controller that exists on the Test Plan tree at the same level as the Thread Group element. It is distinguished from a Thread Group in that it is not executed unless it is referenced by either a Module Controller or an Include_Controller.

> This element is purely for code re-use within Test Plans

1.3) Listeners

> Listeners show the results of the test execution. They can show results in a different format such as a tree, table, graph or log file

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

Different Listeners provided by JMeter are:

View Results in Table
View Results Tree
Aggregate Report
Aggregate Graph
Assertion Results
Backend Listener
BeanShell Listener
Graph Results
Mailer Visualizer
Monitor Results
Response Time Graph
Save Response to a file
Simple Data Writer
Summary Report

1.4) Timers

> By default, a JMeter thread executes samplers in sequence without pausing. We recommend that you specify a delay by adding one of the available timers to your Thread Group. If you do not add a delay, JMeter could overwhelm your server by making too many requests in a very short amount of time.

Timers provided by JMeter are:

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

1.5) Assertions

> Assertions are used to validate the sampler response received from the server. In order to test a sampler response, we add different assertions to the sampler. If an assertion fails, the sampler response is marked as failure and the same gets reflected in the test results.

Different Assertions provided by JMeter are:

Response Assertion
The response assertion used in test scripts to validate a pattern in the response body, header, code, message etc. There are different pattern matching rules to validate the response like-

Contains – If the response text contains the regular expression to be matched
Matches – If the whole response text matches the regular expression
Equals – If the whole response text matches the pattern(not regular expression but the pattern string)
Substring – If the response text contains the pattern(not regular expression)
Not – To check that the pattern is not present in the response text

HTML Assertion
Size Assertion
Compare Assertion
BSF Assertion
Duration Assertion
XML Assertion
The XML assertion is used to validate that the response follows a valid XML syntax.
XML Schema Assertion
MD5Hex Assertion
SMIME Assertion
JSR223 Assertion

1.6) Configuration Elements

> Configuration Elements in JMeter are used to configure or modify the sampler requests made to the server. These elements are added at the same or higher level of the samplers they want to configure.

Configuration Elements that JMeter provides:

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

1.7) Pre-Processor Elements

> A Pre-Processor executes some action prior to a Sampler Request being made. If a Pre-Processor is attached to a Sampler element, then it will execute just prior to that sampler element running.

> A Pre-Processor is most often used to modify the settings of a Sample Request just before it runs, or to update variables that aren’t extracted from response text.

1.8) Post-Processor Elements

> A Post-Processor executes some action after a Sampler Request has been made. If a Post-Processor is attached to a Sampler element, then it will execute just after that sampler element runs.

> A Post-Processor is most often used to process the response data, often to extract values from it.


Apache JMeter Test Plan Elements Tutorial

Execution order of Test Elements

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

Follow me on social media: