- Introduction:
WHY JMETER?
Jmeter Installation:Operating system Support for JMeter
JMeter is a pure Java application and should run correctly on any system that has a compatible Java implementation.
Here is the list of operating system compatible with JMeter.
In this tutorial, we run JMeter on Window operating system
Steps to Install JMeterStep 1) Install Java
Because JMeter is pure Java desktop application, it requires a fully compliant JVM 6 or higher. You can download and install the latest version of Java SE Development Kit.
After installation is finished, you can use the following procedure to check whether Java JDK is installed successfully in your system
If Java runtime environment is installed successfully, you will see the output as figure below
If nothing displays, please re-install Java SE runtime environment
Step 2) Download Jmeter
Choose the Binaries file (either zip or tgz) to download as shown in figure below
Step 3) Installation
Installation of JMeter is extremely easy and simple. You simply unzip the zip/tar file into the directory where you want JMeter to be installed. There is no tedious installation screen to deal with! Simple unzip and you are done!
Once the unzipping is done installation directory structure should look like as figure below
Given below is the description of the JMeter directories and its importance JMeter directory contains many files and directory
Step 4) Launch JMeter
You can start JMeter in 3 modes
Start JMeter in GUI Mode
If you are using Window, just run the file /bin/jmeter.bat to start JMeter in GUI mode
Following figure annotates the various components in the JMeter GUI
Start JMeter in Server Mode
Server mode is used for distributed testing. This testing works as client-server model. In this model, JMeter runs on server computer in server mode. On client computer, JMeter runs in GUI mode.
To start the server mode, you run the bat file bin\jmeter-server.bat as below figure
Start JMeter in command line mode
JMeter in GUI mode consumes much computer memory. For saving resource, you may choose to run JMeter without the GUI. To do so, use the following command options
This is a command line example
$jmeter -n -t testPlan.jmx - l log.jtl -H 127.0.0.1 -P 8000
Additional Packages
Based on your requirement, you will need one or more optional packages listed below.
Java Compiler allows developers to build JMeter source code and other JMeter plugins
SAX is the Simple API for XML, originally a Java-only API. You can use SAX XML parser as an alternative to XML parser in JMeter
JMeter has extensive Email capabilities. It can send email based on test results and has a POP3(S)/IMAP(S) sampler. It also has an SMTP sampler.
If you want to test database server, you have to install JDBC driver
Use JMeter in Linux
How Apache JMeter works
For using JMeter, you need to define your test plan. Which basically means, you have to specify
So a complete test plan contains samplers, listeners etc. To create it, you right click on "Test Plan" on the left-hand pane of JMeter GUI and add required elements. These terms are explained below briefly:
JMeter's Test elements explained briefly :
Usage of HTTP Sampler for a basic http test:
Let's write our first web test plan for testing an http url. So here are the steps. The screenshots are provided below.
The steps are as follows:
Image 4 : Give a name to HTTP Sampler, add hostname and webpage path.Top of page
Introduction to Config Element
Config Element is a convenience element where you can store the common configuration values of all samplers like webserver's hostname or database url etc.
Example of HTTP Request Defaults Config Element (sample usage)
If you need to test dozens of http urls, then instead of adding the webserver's hostname or proxy details etc in all HTTP Request Samplers, you can put these in The Config Element HTTP Request Defaults. This will avoid repetition of data and also make the config manageable. Let's see an HTTP Config Element in action
Image 1 shows how to add an HTTP Config Element and Image 2 show how to configure 1. Image 1: Adding HTTP Config Element Image 2: Configuring HTTP Config element
CSV Data Set Config:
You
can parameterize
the
script to enter different login
credentials.
This login information (e.g. Username, password) could be stored
in
a
text file, JMeter
has an element that allows you to read different
parameters
from
that text file. It is "CSV Data Set Config", which is used to
read
lines
from a file, and split them into variables.
HTTP Cookie Manager:
In
Browser, your username and password will
be
stored
in your computer as cookies. Next time, when you visit
same
website,
you don't need to do login again because your browser will
use
your
cookies as user data to login.
Http Request defaults:
You are sending 100 HTTP requests
to the server
google.com.
You would have to manually enter server name = google.com
for
all
these 100 requests.
Instead,
you could add a single HTTP request defaults with the
"Server
Name or IP" field = google.com, No need to type 100 times!
Login Config Element vs CSV Data Config:
In Login Config only one users credentialscan be simulated where as in CSV Data set config multiple users credentials (values) can be read from a file.
Steps
to Record a Script using Jmeter:
Select
Work
Bench, Add >Non-Test Elements >HTTP(S) Test Script Recorder
Settings to be done in Test
Script Recorder:
Port Setting-8080, Including or
Excluding URL Patterns (Optional)
(e.g. *.html, *.php, etc.),
Then press
Start Recording.
Configure Firefox To Use JMeter
Proxy:
Open
Firefox > Preferences
>
Advanced
tab > Network > Connection
Setting > Select
the "Manual proxy configuration > Set
HTTP Proxy to
"localhost"
and Port to
"8080” > Check
"Use
this proxy server for all
protocols“> OK.
CREDITS: As i learnt on my own from various tutorials, i would like to thank GURU99 and some other tutorials for the Knowledge. |