Вы находитесь на странице: 1из 92

QUALITY THOUGHT JMETERMATERIAL

JDK, JVM & JRE

JDK – Provide environment to Develop and run java application

JRE – Only to run Java applications

JVM – Which is the component in JRE and responsible for execution of Java program, which is
interpreter, which will be responsible to run our java programs line by line.

Open source Vs Commercial


Open Source Commercial
Support less protocols Support more protocols
Limited User Interface Feature rich User Interface
Operations require more steps Operations require less steps
Need more time for modeling Need less time
Free for use Licenses can be very expensive

Performance KPI
 Response Time
 Latency – Subset of RT, (travelling time etc. i.e. only till the 1 byte of the response
received by the browser/client)
 ThroughputQ
1

 How many concurrent users can a web server handle? Or Maximum Concurrent VU?
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 How efficiently it works?


 Business Scenario
 We should use different random data otherwise it will take from the cache & the performance
is very high but this is different from the reality. In each iteration we should use different
random data.
 Environment
o Isolated/Test run during off-hours
o Must be a realistic production like environment
 Test Reporting
o Executive Summary
o Performance Test approach
o Test scripts, test data & test environment
o Test Results
 Benchmarks, Suggested actions,

JMeter
 JMeter is an open source (performance testing tool) desktop Java application with awesome
testing abilities like “designed to measure the performance of web application” i.e.
Performance testing – Testing a web application against heavy load, multiple & concurrent
user traffic.
o How the “Gmail/Facebook/Yahoo/IRCTC” supporting server will perform when
numbers of users simultaneous access the corresponding accounts – basically have to
do performance testing using performance testing tools like Silk performer, VSTS,
JMeter, Loadrunner etc.
2
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 First Developed by “Stefano Mazzocchi” from Apache Software Foundation.


 Initially it is used for testing of web applications, but now using for functional test, DB server
testing etc.
 It is powerful tool with enormous testing capabilities

Pros of JMeter:-

 No license cost i.e. FREE Tool.


 Support many protocols.
 It is 100% Java base application which allows to execute this tool in any platform (so we can
run on any OS where JVM supports).
 Installation is simple; one can install on his desktop and learn it.

Cons

 It’s a open source so no guarantee of support or further development


 One must follow best practices to get better results.
 Adding think times is difficult to get the realistic results.
 No direct support for desktop base applications. Need some workaround to work with
desktop base applications.
3
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Features of JMeter:-

Open Source – JMeter is an open source applicationwhich facilitates users or developers to use
source code for other development.

User Friendly GUI – Extremely easy to use & doesn’t take time to get familiar with it

Platform Independent – It’s 100% pure java desktop application. So it can run on any platforms.
It is highly extensible and capable to load the performance test using many protocols.

Highly Extensible- JMeter is designed based on plugins. So most of its “out of the box” features
are applied with plugins. Using plugins we can write our own test case to extend the testing
process. JMeter uses text editor to create a test plan and supplies in XML format.

Support various testing approach or strategies – JMeter supports various testing approach
such as Load Testing, Stress Testing, Distributed Testing and Functional Testing etc.

Script Test - JMeter is capable to perform automation testing using “Bean Shell & Selenium”.
(Integrated with Bean Shell & Selenium)

Simulation - JMeter can simulate various users with simultaneous threads, generate heavy load
against web application under test.
4
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Full multi -threading framework – It is a full multi-threading framework which permits


simultaneous sampling by many threads and simultaneous sampling of different functions by
distinct thread groups

Visualize Test Result - Test result can be display in a different format such as chart, table, tree
and log file

Easy installation – Just copy and run the *.bat file to run JMeter.

Support multi-protocol: JMeter does not only support web application testing, but also evaluate
database server performance. Below are list of protocolsthat are supported by JMeter

 Web Services – SOAP / XML – RPC


 Web - HTTP, HTTPS (AJAX, Flex etc.)
 Database – JDBC drivers
 Directory – LDAP
 Messaging Oriented Services - JMS
 Service – POP3, IMAP, SMTP, FTP

Record & Playback - Record the user activity on the browser and simulate them in web
application using JMeter

Email Support –JMeter has extensive Email capabilities, so JMeter send emails based on the test
results.

JMeter Architecture working Process –

The following diagram shows the process

5
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

How JMeter Tool works?

 JMeter simulates a group of users sending requests to target server and return statistics
information that shows the performance/functionality of target server/application via
tables, graphs, summary table etc. Based on the above we will analyze the test results
and prepare the reports.

6
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Installation of JMeter:-

 Before installation we need to check the system is supporting Java or Not if not install
Java. Use the below command to check Java is installed or not on the system
 In Windows/Linux, open the Terminal and type the command “java –version”
o If Java run time is installed successfully then below is the corresponding output.

o If java run time is not installed the below is the corresponding output

 If OS is Mac, the command to find the java version is “machine: ~ joseph$ java –version”
 Pre-requisite - Should have latest version of Java Development Kit.I.e. JVM o JKD 6 or
higher.

OS Windows Windows Linux 2.4, MAC


XP 7 2.6,3.1
JVM JDK 6, 7, 8 JDK 6, 7, 8 JDK 6, 7, 8 JDK 7
Architecture 32/64 bits 32 bit I386, amd64 64-bit

 The SW is available at
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-
1880260.htmlor
 http://www.java.com/en/download/windows_xpi.jsp
 Download the required JDK and install it. After installation use “java –version” command
to check Java runtime environment is installed or not.
7
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Go to control panel and check Java is available or not and also the version (Programs &
features).

 Now Download JMeter (Choose Binaries) using


http://jmeter.apache.org/download_jmeter.cgi
 After downloading unzip the zip file into the directory where you want install JMeter.
Below is the directory looks like

8
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Bin – It contains JMeter script file for starting JMeter


 Docs –Contains JMeter documentation files
 Extras –Ant related extra files
 Lib – Contains the required Java library files for JMeter
 Lib/ext – Contains the core jar files for JMeter and the protocols
 Lib/junit – Junit library files used for JMeter
 Printable docs –

Future Enhancements in JMeter: -

 Implementation of Web socket Protocol


 Addition of FTPS, SFTP protocols
 Enhancements to Web services protocols (SOAP)
 Enhancements to JMS protocols

Launching of JMeter: - JMeter can start in 3 modes

 GUI Mode
 Server Mode
 Command Line Mode

i) GUI Mode – JMeter runs on client computer. Just click on the file “apache-jmeter-
2.13\bin\jmeter.bat”

9
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

After clicking on the “jmeter.bat” file then it will launch or open the JMeter which is shown below.

 The window has 2 sections


o Left side is Tree view
o Right hand side is a control panel
 Some menu options like File, Edit, Search, Options & Help
 Everything will work with Right click.
 Add Thread Group in the Test Plan (Users = Threads) by right click on the Test Plan
element-AddThreads(Users)-Thread Group
 Now we need to add the request to the thread group i.e. it can be done by adding sampler
(HTTP) [Request = Samplers]. Right click on the Thread Group-Add-Sampler-HTTP
Request
 Don’t put the HTTP://in Server Name or IP filed
 Path /
 Now we need “Report” to see the test results after execution of the request. i.e. Reports in
10

JMeter are called Listeners i.e. Report = Listener (View results in table, Graph results…)
 In order to run the test need to save the test (Click Save)
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Click on Start button.


 JMeter doesn’t clear the previous test run results (Using tool bar icon to clear all the
results)
 Sample Time(ms) – Which includes all the time (request going to server, processing &
sending the response to JMeter)
 Stop – Immediately stops irrespective of the thread status
 Shutdown – Complete the current iteration and then it will stop the execution

ii) In Server Mode – JMeter runs on server computer

 It is used for Distributed testing i.e. Testing works as Client-Server mode


o JMeter runs on Server Machine in Server Mode
o On client computer JMeter runs in GUI mode
o To start the server mode click on “jmeter-server.bat” file in bin folder.

iii) JMeter inCommand line mode


 In GUI mode the JMeter consumes much computer resources (memory etc.) So for saving
resource we can run JMeter in command line….
 Command - jmeter -n -t testPlan.jmx -l log.jtl –H 127.0.0.1 –P 8000
o Jmeter –n====== Specifies that JMeter is to run in Non-GUI mode i.e. in
command line mode
11

o –t Text.jmx===== Name of the file contains Test Plan


o –l log.jtl======== Name of the JTL file which contains the test results
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o –H 127.0.0.1==== Proxy server hostname or IPAddress


o –P 8000 ============ Proxy server port number

Additional Packages available in JMeter

 Java Compiler – Allows developers to build JMeter source code & other JMeter plugins
 SAX XML Parser – It is simple API for XML, we can use SAX XML parser as an
alternative to XML parse in JMeter
 Email Support available in JMeter using POP3/IMAP sampler.
 JDBC Driver – Can test the DB server.

Different components (Elements) of JMeter

 In JMeter each component is called Elements

Test Plan:-
 It is top level body of JMeter, which explains the sequence of steps to execute at run time.
 A final test plan has “one or more Thread groups, Sampler, Logic Controllers, Listeners,
12

Timers, Assertions and configuration elements.


 Each sampler can be preceded by one or more Pre-processor elements, followed by Post-
Page

processor element & Assertion elements…

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 It saves the file in “Java Management Extensions (JMX) format.


 JMX is an open text based format, used across dissimilar systems. Using this we can open the
test plan in text editor and can use “Find and Replace” functions/Web server names/ID’s etc.
(Which might appear more number of times) with little determination.

The Test Plan looks like as below

13
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Parameters:-

 Name: Specify the Name for the test plan. Ex: USA Bank etc.
 Comments: Provide any comments if necessary
 User Defined Variables – We can define any variable that will be used in the JMeter scripts.

Check Box Options

 If we check Run Thread Groups consecutively (i.e. run groups one at a time) – Then JMeter
will run the Thread Groups in the Order they have defined. Ex: I have 2 thread groups in my
test case. Group A should complete first before Group B starts to execute.
 Run teardown Thread Groups after shutdown of main threads–If we check this option
then the “teardown” thread group will execute after shutdown of the mail thread or main load
test.
 Functional Test Mode – If we check this option then JMeter will store the data for the page
requested (response, user input data or sample data) in a log file. This will be used when you
want to use JMeter as a functional testing tool.

Work Bench:-

 The workbench provides a place to store test elements temporarily. Not bonding with the
Test Plan.
 JMeter will not save the content of Work Bench, It will save only the contents of Test Plan.

Recording Script with JMeter:-

Steps required for recording HTTP/HTTPS traffic:-

 Start the JMeter in GUI mode. (C:\\JMeter\apache-jmeter-2.13\bin “jmeter.bat” )


 Click on templates (File-Templates), select template as “Recording” and click on Create
button.
 Now select the HTTP(S) Test Script Recorder in the work bench. 14
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Here we need to remember 3 important things before recording the script with JMeter.
o JMeter will record the browser action using a proxy server, so we need to configure
our browser to use the JMeter proxy.
o JMeter needs port to record browser actions, so need to provide the port number that
is not in use in our Test Controller in the port section as shown in the above diagram.
o If the port number mentioned in the port section EX: 8888 is free then we will not get
any error after click on the start button
o If the port number mentioned in the port section is already using by other applications
then we will get the below error after clicking on the start button.

o So we need to identify the port number that is not in use by using “netstat –a”
command in the command line and enter the port number that is not in use. (Should
15

not use the state of the port as “LISTENING”, “ESTABLISHED”) in the netstat –a results.
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

16
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 By default we need to keep the Target Controller as “Use Recording Controller”


for script recording. If you are recording the script more than ONE time then
add another controller and then change the target controller to the newly added
one.
 Before recording the script need to confirm with application team
(Product Owner/Dev Manger) regarding the downloaded stuff like “Java
Scripts”, Images, CSS, woff files etc.
 Depending upon their required if they want to execute the load test by
keeping the stuff then we need to remove the default content from URL
Patterns section. If they don’t’ want the downloaded stuff then we need
to keep the default URL Patterns to exclude.
 Now before starting the JMeter proxy server we need to configure our browser with the same
port number that we are using the HTTP Test Script Recorder. Below are simple steps to
configure the browser to use the JMeter proxy.
o Launch FireFox (IE,Chrome) browser, click on Tools-Options-Advanced-
Network-Settings.
o In the connection Settings window select the radio button as “Manual proxy
configuration” and enter “localhost” in the HTTP Proxy section and port as same port
that we have used in the HTTP Test Script Recorder.
o Click on the Check box for “Use this proxy server for all protocols.

17
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o Click on OK button.
o Now click on “Start” button in JMeter proxy server i.e. in the HTTP(S) Test Script
Recorder and launch the Firefox browser and execute the steps for the Performance
Scenario.

Threads (Users):-

 Threads are beginning or first element in any Test Plan.


 It represents the number of Virtual Users.
 NO test plan is exist without Threads.
 In JMeter we have 3 types of Threads
o Thread Group
18

o setUp Thread Group


o tearDown Thread Group
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Thread Group:-
 It is an initial stage of test plan. It represents group of Threads i.e. group of Users.
 Each thread represents one virtual user using the application under test. (i.e. each user
simulates one real user request to the server)
 The controls for a thread group allow you to set number of threads for each group. i.e. if the
controls value is 100 then JMeter will creates & simulate 100 users request to the server. And
also we can control Ramp Up and the number of test iterations.

Parameters:-
 Action to be taken after a sampler error
o Continue – If we selected this option then the test will continue even after getting an
error for a request
o Start Next Thread Loop –If we select this option, and if we get an error for any request
then JMeter will stop the current loop and start the next loop for the same thread.
o Stop Thread –Kill the current thread only
o Stop Test –if Sample error occur then all threads stops its execution at the end of the
current samples.
o Stop Test Now - if Sample error occur then all threads stops abruptly
 Number of Threads – Which describes the total number of threads or users used to execute
19

the Test Plan i.e. load test. Each and every user will execute the test plan completely based on
Page

the conditions.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Ramp-Up Period (Sec) – The time to load all users given in. For EX: 100 threads and Ramp-
Up Period is 100 sec then JMeter will load all 100 users in 100 sec i.e. for every 1 sec the user
will be loaded.
 Loop Count – Which describes how many time the test plan should be executed.
o If we set 5 in the Loop count then JMeter will execute entire test plan for 5 times
o If we select option Foreverthen the test plan will run for forever, we have stop it
manually to stop the load test.
 Delay Thread creation until needed -
 Scheduler –Using this we can specify the stat time (when to start the load test), end time
(when to End the load test), duration (how much time the test to be executed) and start up
delay (using this option we can delay the starting of the load test) of the load test.

setUp Thread Group:-


 It is a special type of thread group and it can be utilized to perform Pre-Test Actions.
 Behaves same as normal Thread group only but the difference is we can execute this thread
group before the actual thread group executes.
20
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

tear Thread Group:-


 It is a special type of thread group and it can be utilized to perform Post-Test Actions.
 Behaves same as normal Thread group only but the difference is that this thread group is
executes once the test has finished its execution.
 Need to check the option “Run tearDonw Thread Groups after shutdown of main threads”

Test Fragment:-
21

 It is a special type of element placed at the same level as Thread Group element.
Page

 Just holding other elements inside it

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 It gets executed only when it is referenced by a Module or include controller from other
thread groups.
 It acts like a library of reusable of scripts. This element is purely for code re-use within Test
Plan.

Example: In the below example we can see 2 thread groups one for User Login and Order Creation,
another one is User Login and Product view.

Whenever there is change in the login functionality then we need to ensure that we should update
the login script in both the thread groups.

So instead of duplicate this login in both the thread groups we can define this login functionality in
Test Fragment and use the same in Module controller and put this module controller in both the
thread groups.

22
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Now if the login script changes then we can update the login script under Test fragment only…..so
that the both thread groups will work fine.

Configuration Elements:-
 It is a simple element where we can collect the Required Information for all the samplers. I.e.
for Web Server Hostname, DB URL, any constants etc.
 It will allow us to setup “Defaults” and “Variables” for later use by Samplers.
 These are executed at the start, before samplers executes.
 These are used to add or modify requests made by samplers.
 It can be accessible only from inside where you place the element. For Ex: if we place an HTTP
Cookie Manager inside a simple controller then the Cookie Manager will only be accessible to
HTTP Request which is placed inside the simple controller but not from the outside of logic
controller.

 As you can see from the above picture, we can say that the HTTP cookie Manager is place in
inside a simple controller, so now the HTTP requests which are place inside the simple
controller can only access cookie manager. In our case “HTTP Request 1 and HTTP Request
2” can access HTTP Cookie Manager but not Http Request 3 since it is placed outside the
controller. So it is very important where you place your configuration elements.
 JMeter provides different types of Configuration Elements and they are
o Counter
o CSV Data Set Config
o FTP Request Defaults
o HTTP Authorization Manager
o HTTP Cache Manager
o HTTP Cookie Manager
23

o HTTP Request Defaults


Page

o HTTP Header Manager

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o Java Request Defaults


o Keystore Configuration
o JDBC Connection Configuration
o Login Config Element
o LDAP Request Defaults
o LDAP Extended Request Defaults
o TCP Sampler Config
o User Defined Variables
o Simple Config Element
o Random Variable

24
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Counter:-
 Using this we can create counter that can be used anywhere in the Thread Group.
 We can specify the starting point, maximum and increment values in the counters.
 We can define variable name which hold counter value, which can be used in the script.
 The counter will loop from the start to the max and then start over with the start and continue
like that until the test is ended.

 Using this we can create counter and that can be used anywhere in the Thread Group.

CSV Data set configuration:-

 During execution of load test we will simulate the real user actions by enter some data like
Customer name in case of “Search Customer” transaction, this can be achieved using CSV data
set config element in JMeter.
 This confg element is used to supply random data to JMeter variables from external CSV files.
 We can use the same CSV file to supply all the required data for all threads (users) or we can
have different files.
 All threads can use separate row data from csv files, starting from line1….line n
 Order of picking data from CSV will depend of order of execution of different threads
 Need to supply the location of the data file to the JMeter so that JMeter take the values from
the CSV file.
25
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Generation of random data at run time is expensive in terms of CPU & Memory usage, so in
general we will create the data in advance of the test and use the same in load testing.
 By default the file is opened once and each thread will use different line from the CSV file.
 When the end of file (EOF) is reached, and the recycle option is true then the reading starts
again with the first line of the file.
 Sharing Mode has
o All Threads – The file is shared between all the threads
o Current Thread Group – Each file is opened once for each thread group.
o Current Thread – Each file is opened separately for each thread.
 Data defined in the file should follow the order in which variable names are defined. For
example from the above picture, the variable name order is “UserName”, “Password”, so now
my test data file should like this

FTP Request Defaults:-


26

 It is associated with FTP Request Sampler.


Page

 This is used when we are going to send the multiple requests to the same FTP server.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 EX: We have a script for FTP application and we have around 100 requests for the scenario,
unfortunately the app team moved the FTP server to some other location or changed the
name of the FTP server.
o Now we need to modify our 100 FTP requests to the modified location, suppose if we
have 500 FTP request then?
o So instead of going and modifying the server name in each FTP request, JMeter
provided the FTP Request defaults config element where we can define the location
and port through which we can access the server and perform required operations.
o If we use this element then no need to enter the same information in each FTP request.

HTTP Authorization Manager:-

 The Authorization Manager lets you specify one or more user logins for web pages that are
restricted using server authentication.
 When you access some web applications (restricted pages) then the browser will display a
login dialog box to access the application.
 JMeter transmits the login information when it encounters this type of pages.

27
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 JMeter checks each entry in turn and stops when it finds the first match, so we need to
specifies the most specific URL should be appear first in the list.
 JMeter ignore the duplicate URL’s.
 When we execute a Test Plan, then JMeter looks in the Authorization table for the URL it is
requesting, if the base URL matches the URL in the authorization Manager then JMeter passes
this information along with the request.

HTTP Cache Manger:-


Web-browsers have some mechanisms which allow for the reduction of traffic over the Internet.
One such item is the caching of resources downloaded from the network, for use in the subsequent
requests without triggering the web-server. That's why it's extremely important to reproduce the
same behavior while creating a performance test.

 It is used to implement browser cache functionality in our test Plan (i.e. to HTTP requests).
 Each Virtual User thread has its own cache; by default Cache Manager will store up to 5000
items in cache per Virtual User Thread.
 Note that the more you increase this value the more HTTP Cache Manager will consume
memory of the Test controller where you have executing the Load test. If this parameter is too
high, you will easily get an OutOfMemoryException.
28
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 If we select the check box “Clear Cache Each Iteration” then the JMeter will clear cache at the
start of the thread.
 If we select the option “Use Cache-Control/Expires header when processing GET requests”
then the GET request first look into the cache and returns immediately without requesting the
URL from the remote server. This is intended to emulate the browser behavior.
o If the requested document has not changed since it was cached, then the response
body will be empty.
o If the requested document has not changed, than it will be taken from cache. And,
obviously, this will influence response time – it will become much shorter.

HTTP Cache Manager represents browser cache, it means that embedded resources
(images, scripts, styles) are downloaded once and any subsequent calls to these resources do
not trigger HTTP Request to the application or web server and element is returned
immediately from cache. This is how browsers work and this is how you should configure
your JMeter.

HTTP Cookie Manager:-

 When we are accessing any web application in IE/FF/Chrome etc.Browsers and login into the
application then the computer will store this information in a “Cookie”.
 Next time if we visit the same website then we don’t need to do the login again because the
browser will use the cookie as user data to login into the web site.
 In JMeter HTTP Cookie Manager will do the same like a web browser I.e. if the HTTP request
sends to the server and response contains a cookie then HTTP Cookie Manager will
29

automatically stores that cookie and will use it for all future requests to that particular web
Page

site.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 JMeter thread has its own “cookie storage area”. So if we are testing a web site that uses a
cookie for storing session information, then each JMeter thread will have its own session.
o Maintain a separate copy of cookies for each thread.
o It saves cookie value internally; we can’t view that, to view it we need to go to Tree
Listener.
o We can add user defined cookies here.

HTTP Header Manger:-

 Using this we can add or override HTTP request headers.


 JMeter supports multiple header managers.

 Header manager entries are merged to form the list for the sampler.
 If any entry to be merged matches an existing header name, then it replaces the previous
entry.
 So using this we can set up a default set of headers to particular samplers.

HTTP Request Default:-

 This element lets you to set the Default values that the HTTP Request to use. This is similar to
FTP Request Default.
 We have created a test plan with 50 HTTP requests and all of the requests are being sent to
the same server. If we add a single HTTP Request Defaults and specify the Server Name or IP
Address and we will update the entire HTTP requests with Server Name field as empty, then
the controller will inherit this field (Server Name or IP Address) from the HTTP Request
30

Default.
 If you are sending 100 HTTP request to IRCTC site in a single transaction then we should have
Page

to enter 100 times the server site or IP Address or Server Name for all 100 requests, Instead

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

of this we can use “The Single HTTP request Defaults” and make the IP Address filed as empty
in the HTTP Request element.

JAVA Request Default:-

 This element lets you to set the Default values for the JAVA testing.

JDBC Connection Configuration:-

 This element creates a database connection.


31
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 The Database URL and JDBC Driver class are defined by the provider of the JDBC
implementation.

LDAP Request Defaults:-

 This element creates a LDAP connection.

32
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Login Config Element:-

 This element is used to add or override the user name and password setting in the sampler.
 Suppose if we want to execute one user login to gmail.com or facebook.com with username &
password then we can use this element instead of CSV file.

Random Variable:-

 This element is used to generate the numeric strings and store them in a variable and use it in
the scripts.

 Need to specify the variable name to store the random number.


 Output format specifies the length of the random number. For Example If we specify 000then
it will generate number with at least 3 digits. Here USER_000 means USER_nnn where n is
number from 1 to 9.
 If we specify the Minimum and Maximum numbers then JMeter will generate the random
33

number in between.
 If Per thread is FALSE then it is shared between all the threads in the thread group, if it is
Page

TRUE then each thread has its own random generator.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Seed for Random function – By default it will take the current time in milliseconds, if we use
same value (Ex: 5) then it will generate same value for each thread.

Simple Config Element:-


 This element is used to add or override arbitrary values in the samplers.
 This is primarily for developers as a basic GUI that they can use while developing new JMeter
components.

TCP Sampler Config:-


 This element is used to provide the default data for the TCP samplers.

34
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

User Defined Variables:-

 This element is used to define the initial set of variables. Placed at the start of the Thread
Group
 If you have more than one Thread Group, then make sure to use different names for the User
Defined Variables.
 UDVs are processed in the order they appear in the Plan, from top to bottom.

Timer:-
 By default JMeter will send the request without pausing between each request but this is not
exactly realistic. If the continuous requests are sending to the server by JMeter then test
server may hang or server may face overload issues. So to simulate real traffic JMeter
provides Timer elements.
 In general user spends some time before submitting a form or moving to next page etc.
 We can achieve using Timer element in JMeter.
 A timer allows you to define a period to wait between each request.
 When we add timer before a sampler (request) then JMeter pauses for that time before
sending a request.
 Below are the list of the timers supported by JMeter
o Constant Timer
o Constant Throughput Timer
o Uniform Random Timer
o Gaussian Random Timer
o BeanShell Timer
o Poisson Random Timer
o BSF Timer
35

o JSR223 Timer
o Synchronizing Timer
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Constant Timer:-
 Using this timer we can delay each user request for the same amount of time.

Constant Throughput Timer:-


 Constant Throughput Timer will introduce random delays between requests in such a way
that a load or stress test required throughput is sent to the application.
 This will works on sampler’s per minute basis. Suppose our requirement is 5 request should
be sent to the server per second then it will become 300 requests per minute. And we want to
maintain this throughput among all threads. So JMeter engine will start all threads with in the
given ramp-up time but it will allow only 5 samplers (requests) to execute at a given second
i.e. only 5 request/sec.
 Using this timer we can achieve the required through put.
 The throughput will be lower if the server is not capable of handling the requests

Uniform Random Timer:-


 Uniform Random Timer will delays each user request for a random amount of time.
 It will delay consecutive requests of the same thread by a random interval within lower and
upper bounds.
36
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Here fixed component is called Constant Delay Offset = 1000 ms, Variable component that will
vary between 0ms and the value of field Random Delay Maximum.
 Here Total Delay is the sum of the random value + Constant Delay Offset value.

Gaussian Random Timer:-


 Gaussian Random Timer is same as Uniform Random Timer except that in this it will delays
each user request for a random amount of time.
 To delay every user request for random amount of time then we will use “Gaussian Random
Timer” with most of the time intervals happening near a specific value.
 Gaussian Random means with most of the time intervals arising near a specific value i.e.
Constant interval & varying between constant interval and deviation.
37

 Deviations (millisecond) – A parameter of Gaussian Distribution function


 Constant Delay Offset – Additional value in milliseconds
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Total Delay Time = Return value of Gaussian Distribution function + Additional value in
millisecond

 So the total delay is as below

Bean Shell Timer


 Between each user request, the Bean Shell Timer can be used to create a delay time.
38
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Poisson Random Timer


 To pause each and every thread request for random amount of time use Poisson
Random Timer with most of the time intervals occurring close a specific value.

39

 Total Delay = Sum of poisson Distributed Value and Offset value.


Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

BSF Timer
 Between each user request, the BSF Timer can be used to create a delay time using BSF
scripting language.

JSR 223 Timer


 Between each user request, the JSR223 Timer can be used to create a delay time using
a JSR223 scripting language.

Synchronizing Timer
 This Timer is used to synchronize requests of various threads i.e. It will increase delays
between requests so that all threads fire at the same time there for generating heavy
load bursts on the application.

Pre-Processor Elements:-
 It is an element which runs just before a sampler executes.
 They are often used to modify the settings of a Sample Request just before it runs. Or update
variables that are not extracted from response text
 It is used to perform some action, if it is added to any sampler then it will be used to perform
configuration setting for samplers, it will always execute before sampler.
 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
40
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Below are the list of the Pre-Processor elements supported by JMeter


o BeanShellPreProcessor
o BSF PreProcessor
o HTML Link Parser
o HTTP URL Re-writing Modifier
o JDBC PreProcessor
o JSR223 PreProcessor
o RegEx User Parameters
o User Parameters
 If we add any one of the above pre-processor in a Request (sampler) then it will retrieve the
required data from the previous request response and will use in the current request.

41
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

HTTP URL Re-writing Modifier:-

 This modifier is used to “URL Re-writing to store session id’s instead of cookies” in a request.
 This modifier can be added either with sampler or with the Thread Group.
 For Example:
o Some web applications that will use session id’s instead of cookies, then this HTTP URL
Re-writing Modifier elementis used to store session id’s. We will give simply the name
of the session id parameter so that the element will on the previous request and add
the value to every request when we add the element at the thread group or to the
particular request where this element is added.
o One of the web application request is sending the below parameters while sending the
request to the server

o Here the session id is dynamic.


o To customize this we need to add HTTP Re-writing Modifier (Add-Pre-Processor-
HTTP URL Re-writing Modifier) to the required sampler.
o Here the Session parameter name is “BV_SessionID”

o Now we need to change the variable values to * in the sample.


42
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o Save and run the script then the script will pass.

HTML Link Parser

 This preprocessor parses the response of the server & extract links and the forms.

The sampler on which this pre processer is applied, will be examined to see if it matches any of the
link or the forms which is extracted by preprocessor from previous response, if yes then it replace
the value in URL with value hold by preprocessor.

Consider a simple example: let’s say you wanted JMeter to “spider”(Randomly Clicking links in JMeter)
through website under test, parse link (check all links on the page) and return the HTML. You would
add some action such as “HTML link parser” to your controller before creating an HTTP request.

User Parameters:-

 This will allows the user to specify values for User Variables specific to Individual Threads.
 We can specify these values at the Test Plan but if we want to allows to specify a series of
values for any User Variable then we will use this element.
 For each thread the variable will be assigned one of the values from the series in sequence, if
there are more threads than values then values get re-used.
43
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

JDBC Pre-Processor

 This enables us to run some SQL statement just before a sample runs.
 This is useful if the JDBC sample requires some data to be in Data Base and we can’t compute
this in a setup Thread group.

There are 2 controllers

o Sampler controller
44

o Logical controller
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Samplers:-
 Samplers facilitate JMeter to deliver explicit types of requests to the server. I.e. it simulates a
users’ request for a page from the target server so that, to avail POST, GET, DELETE function
on a HTTP service, user can add HTTP Request sampler.
 Apart from HTTP sampler, JMeter supports testing of FTP, JDBC, Java Requests, SOAP/XML
Requests, RPC requests.
 Sampler specifies the type of the requests i.e. FTP request/HTTP Request/JDBC Request/ etc.

FTP Request:-

 If you are doing a performance testing for “FTP” server then we can use FTP request sampler
in JMeter so that this controller lets send an FTP “Download” or “Upload” file request to an
FTP Server

If you want to download a file “Test.txt” from a FTP server then below is the configuration that
we need to do in JMeter
45

 Launch The JMeter


Page

 Right click on “Workbench---Add--Sampler---FTP Request.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Below is the screen shot showing the configuration to download Test.txt file from FTP server.

HTTP Request:-

 This sampler lets you to send an HTTP/HTTPS request to Web Server.


 We will learn more about this in our course.

JDBC Request:-

 This sampler lets you to send a JDBC Request to DB server.

Access Log Sampler:-

 This sampler allows you to read access logs & generate HTTP request.
 The log may be Image/HTML/CSS etc.

SMTP Sampler:-

 This sampler allows you to test a Mail Server. Using this sampler we can send email messages
using SMTP protocol to mail server.

Post-Processor Elements:-
46

 It is a simple element which runs after a sampler finishes its execution.


 This is most often used to process the response data. Ex: Retrieve a particular Value from the
Page

Response

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 For example after sending a request to the Web Server (under test) and we will get response,
support if we get an error in the response and would like to stop the test then we will achieve
this using Post Processor
 JMeter provides the below Post-Processor elements
o Regular Expression Extractor
o XPath Extractor
o Result Status Action Handler
o JSR223 PostProcessor
o CSS/JQuery Extractor
o BeanShellPostProcessor
o JDBC PostProcessor
o BSF PostProcessor
o Debug PostProcessor

Detailed Steps for adding Post-processor to the Test Plan


47

 JMeter sends HTTP request to the web server under test www.google.com.
Page

 JMeter gets response from the Google server.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 If server response is error, JMeter will stop the test.


 If server response OK (no error), JMeter will continue the test

a. Configure Thread Group


b. Add HTTP request default
c. Add HTTP request
d. Add Post-Processor element
 Right Click Thread Group -> Add -> Post Processor -> Result Status Action
Handler

48
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

e. In this Result Status Action Handle Pane, choose Stop Test Now which will stop the
test if JMeter get the error from server response
f. Now update the HTTP Request Defaults with Server name as www.google.co.in/abc

g. Now execute the test and see the results

Regular Expression Extractor:-


 In some situations when you have to extract response from one request and pass it on to
another request. This can be accomplished using regular expression extractor in JMeter.
 Regular expression Testing web sitehttp://www.regexplanet.com/advanced/java/index.html

For Example the Regular Expression for 123 Main St. is \d{1,5}\s\w+\s\w+\.
49

 Java provides java.util.regex package for pattern matching with regular expressions.
Page

 Java regular expressions are similar to Perl programming language.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Regular expression is a special sequence of characters that helps you to match or find strings
or set of strings in the response of a request.

S.No Regular Expression Description Example


Syntax
1 \d Matches any number [0-9]
2 \D Represent anything but a number
(nondigits) [^0-9]
3 \s Represents any space (which is equal
to [\t\n\r\f]
4 \S Represents Anything but a space (non
whitespace) [^\S]
5 \w Any character [a-zA-Z_0-9]
6 \W Anything but a char i.e. Non-word
character :[^\w]
7
8 \b Matches for a space followed by a
whole word.
9 ? 0 or 1 repetitions
10 * 0 or more repetitions
11 {n} Exactly number represent \d{5} – finding 5 digits in
a row
\d{1,5} – finding 1 to 5
digits in a row
12 \B Matches nonword boundaries \$\d*\.\d{2} ----
$100.00
13 \e Escape
14 \f Form Feed
15 \n Newline
16 \r Carriage Return
17 \t tab
18 [a-z] Return any lower case letters Calender Calendar -
Calend[ae]r
19 [0-9]
20 [A-Fa-t0-4] Return all letters from A to F && all
letters from a to t && all digits from 0
to 4
21 ^ Matches beginning of line
22 $ Matches end of line
23 . Matches any single character except
new line.
50

Using m option it allows tomatch


newline as well.
Page

24 [….] Matches any single character in

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

brackets
25 [^…] Matches any single character not in
brackets
26 \A Matches Beginning of string
27 \z Matches End of string
28 \Z Matches end of string except allowable
final line terminator.
29 re* Matches 0 or more of the previous X* – X, zero or more times
thing
30 re+ Matches 1 or more of the previous X+ – X, once or more time
thing
31 re? Matches 0 or 1occurrence of preceding X? – X, once or not at all
expression
32 re{n} Matches exactly n number of X{n} – X, exactly n times
occurrences of preceding expression.
33 re{n,} Matches n or more occurrences of X{n,}-X at least n times
preceding expression.
34 re{n,m} Matches at least n and at most m X{n,m} – X, at least n but
occurrences of preceding expression. not more than m times
35 a|b Matches either a or b
36 (re) Group regular expressions and
remembers matched text
37 (?:re) Groups regular expressions without For grouping
remembering matched text.
38 Matches independent pattern without
(?> re)
backtracking.
39 \w Matches word characters.
40 \W Matches nonword characters.
41 \Q Escape (quote) all characters up to \E
42 \E Ends quoting begun with \Q
43 [abc] a,b , or c
44 [^abc] Any character except a, b or c
45 [a-zA-Z] A through z, or A through Z (range)
46 [a-d[m-p]] a through d, or m through p
47 [a-z&&[^bc]] a through z, except for b and c
[ad-z] subtraction
48 [a-z&&[^m-p]] a through z, and not m through p
[a-lq-z] subtraction
51
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Regular Expression Quantifiers


Regular Expression Description
(Regex)
X? X occurs once or not at all
X+ X occurs once or more times
X* X occurs zero or more times
X{n} X occurs n times only
X{n,} X occurs n or more times
X{y,z} X occurs at least y times but less than z times

Regular Expression Character classes


Regular Expression Character class Description
(Regex)
[abc] a, b, or c (simple class)
[^abc] Any character except a, b, or c (negation)
[a-zA-Z] a through z or A through Z, inclusive (range)
[a-d[m-p]] a through d, or m through p: [a-dm-p] (union)
[a-z&&[def]] d, e, or f (intersection)
a through z, except for b and c: [ad-z]
[a-z&&[^bc]]
(subtraction)
a through z, and not m through p: [a-lq-
[a-z&&[^m-p]]
z](subtraction)

Regular Expression Meta characters


Regular Expression Description
(Regex)
. Any character (may or may not match terminator)
\d Any digits, short of [0-9]
\D Any non-digit, short for [^0-9]
\s Any whitespace character, short for [\t\n\x0B\f\r]
\S Any non-whitespace character, short for [^\s]
\w Any word character, short for [a-zA-Z_0-9]
\W Any non-word character, short for [^\w]
\b A word boundary
\B A non word boundary
52
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Few Examples:-

Enter your regex: \bdog\b


Enter input string to search: The dog plays in the yard.
I found the text "dog" starting at index 4 and ending at index 7.

Enter your regex: \bdog\b


Enter input string to search: The doggie plays in the yard.
No match found.

Enter your regex: \bdog\B


Enter input string to search: The dog plays in the yard.
No match found.

Enter your regex: \bdog\B


Enter input string to search: The doggie plays in the yard.
I found the text "dog" starting at index 4 and ending at index 7.

Enter your regex:.


Enter input string to search: @
I found the text "@" starting at index 0 and ending at index 1.

Enter your regex: .


Enter input string to search: 1
I found the text "1" starting at index 0 and ending at index 1.

Enter your regex: .


Enter input string to search: a
I found the text "a" starting at index 0 and ending at index 1.

Enter your regex: \d


Enter input string to search: 1
I found the text "1" starting at index 0 and ending at index 1.

Enter your regex: \d


Enter input string to search: a
No match found.

Enter your regex: \D


53

Enter input string to search: 1


No match found.
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Enter your regex: \D


Enter input string to search: a
I found the text "a" starting at index 0 and ending at index 1.

Enter your regex: \s


Enter input string to search:
I found the text " " starting at index 0 and ending at index 1.

Enter your regex: \s


Enter input string to search: a
No match found.

Enter your regex: \S


Enter input string to search:
No match found.

Enter your regex: \S


Enter input string to search: a
I found the text "a" starting at index 0 and ending at index 1.

Enter your regex: \w


Enter input string to search: a
I found the text "a" starting at index 0 and ending at index 1.

Enter your regex: \w


Enter input string to search: !
No match found.

Enter your regex: \W


Enter input string to search: a
No match found.

Enter your regex: \W


Enter input string to search: !
I found the text "!" starting at index 0 and ending at index 1.

Simple

Enter your regex: [bcr]at


Enter input string to search: bat
I found the text "bat" starting at index 0 and ending at index 3.
54

Enter your regex: [bcr]at


Enter input string to search: cat
Page

I found the text "cat" starting at index 0 and ending at index 3.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Enter your regex: [bcr]at


Enter input string to search: rat
I found the text "rat" starting at index 0 and ending at index 3.

Enter your regex: [bcr]at


Enter input string to search: hat
No match found.

Negation

Enter your regex: [^bcr]at


Enter input string to search: bat
No match found.

Enter your regex: [^bcr]at


Enter input string to search: cat
No match found.

Enter your regex: [^bcr]at


Enter input string to search: rat
No match found.

Enter your regex: [^bcr]at


Enter input string to search: hat
I found the text "hat" starting at index 0 and ending at index 3.

Ranges

Enter your regex: [a-c]


Enter input string to search: a
I found the text "a" starting at index 0 and ending at index 1.

Enter your regex: [a-c]


Enter input string to search: b
I found the text "b" starting at index 0 and ending at index 1.

Enter your regex: [a-c]


Enter input string to search: c
I found the text "c" starting at index 0 and ending at index 1.
55
Page

Enter your regex: [a-c]

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Enter input string to search: d


No match found.

Enter your regex: foo[1-5]


Enter input string to search: foo1
I found the text "foo1" starting at index 0 and ending at index 4.

Enter your regex: foo[1-5]


Enter input string to search: foo5
I found the text "foo5" starting at index 0 and ending at index 4.

Enter your regex: foo[1-5]


Enter input string to search: foo6
No match found.

Enter your regex: foo[^1-5]


Enter input string to search: foo1
No match found.

Enter your regex: foo[^1-5]


Enter input string to search: foo6
I found the text "foo6" starting at index 0 and ending at index 4.

Unions

Enter your regex: [0-4[6-8]]


Enter input string to search: 0
I found the text "0" starting at index 0 and ending at index 1.

Enter your regex: [0-4[6-8]]


Enter input string to search: 5
No match found.

Enter your regex: [0-4[6-8]]


Enter input string to search: 6
I found the text "6" starting at index 0 and ending at index 1.

Enter your regex: [0-4[6-8]]


Enter input string to search: 8
I found the text "8" starting at index 0 and ending at index 1.
56
Page

Enter your regex: [0-4[6-8]]

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Enter input string to search: 9


No match found.

Intersections

Enter your regex: [0-9&&[345]]


Enter input string to search: 3
I found the text "3" starting at index 0 and ending at index 1.

Enter your regex: [0-9&&[345]]


Enter input string to search: 4
I found the text "4" starting at index 0 and ending at index 1.

Enter your regex: [0-9&&[345]]


Enter input string to search: 5
I found the text "5" starting at index 0 and ending at index 1.

Enter your regex: [0-9&&[345]]


Enter input string to search: 2
No match found.

Enter your regex: [0-9&&[345]]


Enter input string to search: 6
No match found.

Enter your regex: [2-8&&[4-6]]


Enter input string to search: 3
No match found.

Enter your regex: [2-8&&[4-6]]


Enter input string to search: 4
I found the text "4" starting at index 0 and ending at index 1.

Enter your regex: [2-8&&[4-6]]


Enter input string to search: 5
I found the text "5" starting at index 0 and ending at index 1.

Enter your regex: [2-8&&[4-6]]


Enter input string to search: 6
I found the text "6" starting at index 0 and ending at index 1.
57

Enter your regex: [2-8&&[4-6]]


Page

Enter input string to search: 7

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

No match found.

Subtraction

Enter your regex: [0-9&&[^345]]


Enter input string to search: 2
I found the text "2" starting at index 0 and ending at index 1.

Enter your regex: [0-9&&[^345]]


Enter input string to search: 3
No match found.

Enter your regex: [0-9&&[^345]]


Enter input string to search: 4
No match found.

Enter your regex: [0-9&&[^345]]


Enter input string to search: 5
No match found.

Enter your regex: [0-9&&[^345]]


Enter input string to search: 6
I found the text "6" starting at index 0 and ending at index 1.

Enter your regex: [0-9&&[^345]]


Enter input string to search: 9
I found the text "9" starting at index 0 and ending at index 1.

Enter your regex: a?


Enter input string to search:
I found the text "" starting at index 0 and ending at index 0.

Enter your regex: a*


Enter input string to search:
I found the text "" starting at index 0 and ending at index 0.

Enter your regex: a+


Enter input string to search:
No match found.
58
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Assertions (Verifications) in JMeter

 Assertions play an import role in testing i.e. It’s allow us to include some validations in the
test on the response of the request which is made using Sampler.
 Using assertions we can prove that the application is returning the correct data or It helps to
verify and ensure that testing process is going in a right direction and the server which is
under test returns the expected results.
o For EX: User sends a request to the server
o Server process the request and send the response to the client after some duration
o How user will be ensuring that the coming response from the server is the correct one?
o To resolve this issue, we will use assertions or verification to ensure that the response
comes from the server at run time is correct.
o If response is not correct then the test will get fail for that request
 JMeter highlights when an assertion fails.
 Below are the assertions available in JMeter
o Bean Shell Assertion
o BSF Assertion
o Compare Assertion
o Duration Assertion
o HTML Assertion
o JSR233 Assertion
o MD5Hex Assertion
o Response Assertion
o Size Assertion
o SMIME Assertion
o XML Assertion
o XML Schema Assertion
o XPath Assertion

Response Assertion
 This Assertion will add pattern strings to be compared against various fields of the
server response.
 After sending any request we will get response after some time, now using this
Response Assertion we can verify that the response contains expected pattern string
like “OK” or “Google” etc.
59
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Duration Assertion
 This duration Assertion tests that each server response was received within a given
amount of time or not
 This Assertion will add verify that “Each response comes from the server has received
within a given amount of time or not.
 If any server response takes longer time than the given number of milliseconds
specified by the user then the response get fails.

60
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Size Assertion
 The size Assertion tests that each server response contains the expected number of
bytes in it.
 We can specify the size is equal, greater than, less than, not equal to the given number
of bytes.

XML Assertion
 The XML Assertion tests that the response data consists of a formally correct XML
document or not.
61
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

HTML Assertion
 The HTML Assertion allows user to check the HTML syntax of the response data. i.e.
the response data must be met the HTML syntax.

HTML Assertion
 The XML Assertion allows user to check the HTML syntax of the response data. i.e. the
response data must be met the HTML syntax.

Example – How Response Assertion will work


 1st – Add Response Assertion
 2nd – Add Pattern
 3rd – Add Response Assertion Results
62

 4th – Run Test Results


Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Step1 - Add Response Assertion


 Right-Click Thread Group -> Add -> Assertions -> Response Assertion

 Response Assertion Pane displays as below figure

63

Step2 - Add Pattern to test


 For EX: if you are sending a request to Google server, it may return some value i.e. Response
Page

Code

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

a. 404 – Server Error


b. 200 – Server OK
c. 302 – Web Server redirected to other page etc.
 Now we would like to verify that the response code 302 pattern in the Server Response
 On Response Field To Test, choose Response Code,
 On Response Assertion Panel, click Add -> a new blank entry display -> enter 302 in Pattern
to Test

Step3 - Add Assertion Results


 Right click Thread Group, Add -> Listener -> Assertion Results
64
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

65

Step4 – Run your test


 Click Thread Group -> Assertion Results
Page

 When you ready to run test, click Run button on the menu bar

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 The test result will display on Assertion Results pane. If Google server response code
contains the pattern 302, the test case is passed. You will see the message displayed as
follows:

 Now back to Response Assertion Panel, you change the Pattern to test to from 302 to 500.

 Because Google server response code doesn't contain this pattern, you will see the test case
66

Failed as following….
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Listeners:-
 Listeners facilitate viewers to view Samplers results in different forms. I.e. Listeners will show
the results of the test execution.
 Listeners offer to collect, save and view the results of a test plan and store results in XML
format or CSV format.
 The output can also be viewed directly within the JMeter console.
 We can add these listeners anywhere in the test.
 Different formats like “Table/Tree/Graph/Log file etc. will be available in JMeter
o Graph result listeners will display the Server Response Times on a Graph
o Tree will show the results in basic HTML format
o Table will show the summary of the test results in table format
o Log will show the summary of the test results in text file….
 JMeter provides the below Listeners
o Graph Results
o Spline Visualizer
o Assertion Results
o Simple Data Writer
o Monitor Results
o Distribution Graph (alpha)
o Aggregate Graph
o Mailer Visualizer
o Bean Shell Listener
o Summary Report
67

o Sample Results Save Configuration


Page

o Graph Full Results

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o View Results Tree


o Aggregate Report
o View Results in Table

Logical Controllers:-
 Logical controllers decide the order of processing of samplers in a Thread. It’s a mechanism to
control the flow of the thread group.
 Logical controllers can alter the order of requests coming from their child elements.
 Logical Controllers define the order of processing requests in a thread. i.e. It facilitates users
to describe the sequence of processing request sends to the server in a Thread
 EX: We can use “Random Controllers to send HTTP requests to the server randomly
 JMeter provides the below logical controllers
a. Recording Controller
b. Simple Controller
c. Loop Controller
d. Random Controller
e. Module Controller

Recording Controller
 JMeter can record our testing steps.
 It is a place holder to store the recording steps.

68
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Simple Controller
 It is a simple controller it holds the user requests i.e. It is a container for user requests

Loop Controller
 Using this controller user can run the request for specified number of times or forever.

69
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Random Controller
 Using this controller user can run the request in Random Order in each loop period.
 If we have 3 requests in our script….

a. HTTP Request
b. FTP Request
c. JDBC Request
 Each request runs 5 times
a. i.e. HTTP Request runs 5 Times
b. FTP Request runs 5 times
c. JDBC Request runs 5 times

 For each Loop user request send Sequentially then the order of the request is
a. HTTP Request-- FTP Request-- JDBC Request
 If user send the requests Randomly then
a. FTP Request-- HTTP Request-- JDBC Request
b. JBDC Request-- FTP Request-- HTTP Request

Module Controller
 Using this controller we can add modularity to JMeter.
 Any web application has “Sign-in, Search, Add Customer, and Logout”. This functionality can
be stored in “Simple Controller” as modules.
 Module controller will choose which module needs to run….
70
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

If we want to simulate

 50 Users Logging out


 100 Users Logging in
 30Users Search www.google.co.in
 We can use JMeter to create 3 Modules simulates each user activity – Login, Logout, Search
71
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 The Module controller chooses which module needs to run.

o Runtime Controller
 The Runtime Controller controls how long its children are allowed to run.
72
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o IFController
 The If Controller allows the user to control whether the test elements below it
are run or not.

o Transaction Controller
 Evaluates the overall time taken to complete a test execution.
 In JMeter each HTTP request is represented by a separate request i.e. Images,
styles, scripts etc. So for 1 web page we have N number of samples i.e. N is
always > 1. This doesn't reflect real page load time in the report.
 Real Time Scenario Open Product Search Page → Select a Product → Proceed to
Checkout Page → Checkout.
 The Transaction Controller which generates a “virtual” sample to measure
transaction times.

73
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Look in to above example, There are 2 main HTTP requests. 1. Home Page and
2. FAQ Page. .jpg request, .gif request, .png request and .js request are the sub
requests of Home Page. On completion of recording, i added Transaction
Controller and moved all requests of home page under it. I set 2 virtual users in
thread group and added Aggregate Report Listener to view test results.

 If "Generate parent sample" is checked in transaction controller then you can


view only Transaction Controller line in Aggregate Report as bellow.
Transaction Controller's sub requests will be not displayed in report.

74
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o While Controller
 The While Controller runs its children until the condition is "false".

 Condition blank, LAST, or variable/function


 Blank – Exit loop when last sample in loop fails
 LAST –
 Otherwise – Exist the loop when the condition is equal to the false.
 The condition can be any variable or function that eventually evaluates to the
string "false". This allows the use of JavaScript, BeanShell, properties or
variables as needed.
 ${VAR} - where VAR is set to false by some other test element
 ${__javaScript(${C}==10)}
 ${__javaScript("${VAR2}"=="abcd")}
 ${_P(property)} - where property is set to "false" somewhere else

o Switch Controller
 "Switch Controller" is one of the Logic Controller of Apache Jmeter. As name
suggest, You can switch your targeted software application page request to run
using Switch Controller. You can set your required request id in Switch
Controller to execute it so all other requests under Switch Controller will be
neglected during execution.
 Suppose i recorded apache jmeter testing script for 4 pages -> 1. Home Page, 2.
My Account Page, 3. Login Page and 4. FAQ Page. Now supposing temporarily i
do not want to perform load testing on 'My Account Page'. Then what i can do?
75

1st idea is i will remove that request from load test script and then run test. 2nd
Page

idea is i can use switch controller to exclude that request.

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL


 I set Number of Thread = 3 and Loop Count = 2 in thread group property and
set Switch Value = 0 in Switch Controller property. I run this test and viewed
results in View Results Tree listener as bellow.

76

 See in above image, any request of 'My Account Page' is not display in result
Page

because i set Switch Value = 0 in switch controller so jmeter will consider to

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

execute only 1st request from all requests under switch controller. If i set
Switch Value =1 then all 3 virtual users of Apache jmeter will execute only My
Account Page request. Create script with multiple pages under Switch
Controller for your software application and try above example with different
Switch Values.
o ForEach Controller
o Module Controller
o Include Controller
o Loop Controller
o Once Only Controller
o Interleave Controller
o Random Controller
o Random Order Controller
o Throughput Controller

Example: ForEach controller control panel looks like as below

77
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Order of the Elements that should be executed in Test Plan:-


Following is the Execution Order of the elements in the Test Plan

 Configuration Elements
 Pre-Processors
 Timers
 Sampler
 Post-Processors (unless Sample Result is null).
 Assertions (unless Sample Result is null)
 Listeners (unless Sample Result is null)

Test Plan, Work Bench, Adding/Deleting elements in JMeter


 After opening a JMeter we can see 2 Elements
o Test Plan
o Work Bench

Test Plan
 A test plan contains a series of Elements that are useful in application testing process.
Elements are Thread Group, Logic Controllers, Sample Generating Controllers, Listeners,
Timers, Assertions and Configuration elements.
 Test Plan holds many elements
78
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Work Bench

 It’s a place which creates space to store test elements temporarily at the time of constructing
test.
 In general while designing the Test Script we will do it in Work bench, once it is working fine
then we will move it to Test Plan.
 JMeter saves only the content of Test Plan but not the Work Bench.

Adding Elements

 Adding of Elements in Test Plan is very important step.


 To add elements to Test Plan “right click on the Test Plan which opens context-menu of Test
Plan, then we need to choose required element and then add.
 First we need to add “Thread Group” element which will tell to JMeter that “number of users
needed to be simulate, how frequently the users send the requests, how many requests they
should send etc.
 After defining Users, need to define the task on which the JMeter will work. Ex: HTTP
Requests Defaults Elements add these elements by right click on the Thread Group and add it
“Add-Config Element--HTTP Request Defaults.
79
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 In the similar manner we can add ‘n’ number of elements in the Test Plan.

Removing Elements

 Similar to adding we can also remove the unwanted/unused elements from the Test Plan by
simply right click and Remove.

Saving Elements
 In JMeter we can save entire Test Plan or only the required elements.
 In both the cases the JMeter saves the files with “.JMX” format.
 Saving an Element as below 80
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Saving Test Plan as below

81
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Configure JMeter Elements

 Add the required Element, which will be under Test Plan in the left pane of JMeter GUI
 Do the configuration changes on the right side of the element.

Running/Stopping a Test Plan

 For running of a Test Plan, just click on the RUN button at Top right side corner in the menu
item.
 GUI – Green button

 Command to run the test plan is – “Control+R”


 Menu option – Run--Start
82

 There are 2 ways to stop the execution


o First – Click on Stop or “Control + .”This is immediately process to stop the threads if
Page

possible

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

o Second – Click on Stop or “Control + ,” This appeals the threads to stop at the end of
any present work.

Performance Testing:-
 JMeter provides the following benefits to the system or application under Performance Test
o JMeter is useful to test the performance of static resources such as “Java Script &
HTML, Dynamic resources – JSP, Servlets & AJAX.
o JMeter is useful to find the maximum number of simulated users that use the websites.
o JMeter is useful to provide a various graphical analysis of Performance Reports.

Creation of Test Script in JMeter


 Create Thread Group from the Test Plan, Enter the required information in the Thread Group.
83
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 The required information is “Number Users i.e. Threads, Ramp-Up Period, Iterations i.e. Loop
count” etc.
 If Number of Threads = 100, Loop Count = 10, then JMeter simulates 100 simultaneous users
trying to connect to the target server or website and each user trying to connect the targeted
server 10 times.

 After thread group we need to specify the Type of the Request with which we can connect the
84

web server i.e. protocol which is required to connect to the server.


Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

 Now we are adding HTTP request Default Element, and enter the Server Name or IP Address
of the target server

 Now after opening the google page we need search for anything, support we want to search
for the Performance Testing then we need to enter the text as “Performance Testing” in search
field. This can be done in JMeter by adding a HTTP Requests “
 Add -> Sampler -> HTTP Request.
 Now enter the required text in the path filed

85
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Results Format

 Before executing the test, we need to add the results format in JMeter so that we can view the
results while executing the test.
 Add -> Listener -> View Results Tree.
 Add both Graph results and Table results

Now execute the script and see the results

86
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Detailed Steps for adding Loop Controller to the Test Plan

 These loop controller helps samplers to execute specific number of times with the defined
value for the Thread Group.

Example:-
a. Add one HTTP Request to a Loop Controller with a loop count 50
b. Now configure the Thread Group Loop count to 2, then JMeter will send a total of 50 *
2 = 100 HTTP Requests.

a. Configure Thread Group –


i. Add Thread Group - Right click on the Test Plan and add a new thread group: Add-
>Threads (Users) ->Thread Group and enter the properties as below i.e. 1 User
request to the web server i.e. google.co.in and it will for 2 times

b. Add JMeter Elements


i. Add HTTP request default to www.google.com.
87
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

c. Adding Loop Controller


i. Right Click Thread Group -> Logic Controller -> Loop Controller

d. Configure Loop Controller


i. Enter 50 in the Loop Count field, so it will make one user request to the web server
“google.co.in” run it 50 times (which is independent of the Loop Count value in the
Thread Group.

88
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

ii. In this example, total request sending to the server is 2 * 50 = 100 HTTP Request.
iii. Now add HTTP request to the Loop Controller, Right click Loop Controller, Add ->
Sampler -> HTTP request

e. Add View Results in Table

89

f. Run the test and see the results


Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

Processor in JMeter
 Processors are used to modify the Samplers as per their scope.
 There 2 Types of Processors
a. Pre-Processor
b. Post-Processor

Web Services Testing

In some situations when you have to extract response from one request and pass it on to another
request. This can be accomplished using regular expression extractor in JMeter.

http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL

JMeter Functions
Below table having list of functions available in JMeter are…

S.No Type of Name of the Function Description


Function
1 Information threadNum get thread number
2 Information samplerName get the sampler name (label)

3 Information machineIP get the local machine IP address


90

4 Information machineName get the local machine name


Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

5 Information time return current time in various formats

6 Information log log (or display) a message (and return the


value)
7 Information logn log (or display) a message (empty return
value)
8 Input StringFromFile read a line from a file
9 Input FileToString read an entire file
10 Input CSVRead read from CSV delimited file

11 Input XPath Use an XPath expression to read from a file

12 Calculation counter generate an incrementing number

13 Calculation intSum add int numbers


14 Calculation longSum add long numbers
15 Calculation Random generate a random number

16 Calculation RandomString generate a random string


17 Calculation UUID generate a random type 4 UUID

18 Scripting BeanShell run a BeanShell script


19 Scripting javaScript process JavaScript (Mozilla Rhino)

20 Scripting jexl, jexl2 evaluate a Commons Jexl expression

21 Properties property read a property


22 Properties P read a property (shorthand method)

23 Properties setProperty set a JMeter property


24 Variables split Split a string into variables

25 Variables V evaluate a variable name


26 Variables eval evaluate a variable expression

27 Variables evalVar evaluate an expression stored in a variable

28 String regexFunction parse previous response using a regular


expression
91
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in
QUALITY THOUGHT JMETERMATERIAL

29 String escapeOroRegexpChars quote meta chars used by ORO regular


expression
30 String char generate Unicode char values from a list of
numbers

31 String unescape Process strings containing Java escapes (e.g.


\n & \t)
32 String unescapeHtml Decode HTML-encoded strings

33 String escapeHtml Encode strings using HTML encoding

34 String urldecode Decode a application/x-www-form-


urlencoded string

35 String urlencode Encode a string to a application/x-www-


form-urlencoded string

36 String TestPlanName Return name of current test plan

Time Function
Most of the times we will use different date and time values in the JMeter script, we will get these
values using time function.

 ${__time(dd/MM/yyyy,)}
 ${__time(hh:mm a,)}
 ${__time(dd-mmm-yyyyHHmmss)} 20-032-2015 233224
 ${__time(d-MMM-yyyyhhmmss)} 20-May-2015 113224
 ${__time(dd-m-yyyyhhmmss)} 20-32-2015 113224
 ${__time(D-M-yyyyhhmmss)} 140-5-2015 113224
 ${__time(DD-MM-yyyy)} 140-05-2015
 Sometimes we need to use time in UTC time zone format then we need to use

${__time(yyyy-MM-dd'T'hh:mm:ssX)}

 In one of the script the date value as 13th Nov 2012 17:00 would by 20121113170000, then
the corresponding time function is ${__time(yyyyMMddHMS). Suppose we would use the
same value in different places then we can store this data value in a variable as

${__time(yyyyMMddHMS,DateVariable)
92
Page

QUALITY THOUGHT * facebook.com/qthought * www.qualitythough.in


PH NO: 9963486280, 040-40025423 Email Id: info@qualitythought.in

Вам также может понравиться