Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

JMeter Interview Questions

QUESTION: What is JMeter?

ANSWER: JMeter is one of the Java tools which is used to perform load testing client/server
applications. Apache JMeter is open source software, a 100% pure Java desktop application designed
to load test functional behavior and measure performance of the application. It was originally
designed for testing Web Applications but has since expanded to other

test functions.

 Java Based Window Application.

 Support many type of applications like HTTP, Web

Service, LDAP, JDBC, Java, FTP etc.

 Support Distributed Testing: So that we can distribute load on multiple machine, so that we can
simulate load on server, network or object which are coming from different machine to implement
real world scenario.

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

QUESTION: What are the protocols supported by JMeter?

ANSWER: The protocols supported by JMeter are: Web: HTTP, HTTPS sites 'web 1.0' web 2.0 (ajax,
flex and flex-ws-amf)

Web Services: SOAP / XML-RPC

Database via JDBC drivers

Directory: LDAP

Messaging Oriented service via JMS

Service: POP3, IMAP, SMT P

FTP Service

QUESTION: List some of the features of JMeter.

ANSWER: Following are some of the features of JMeter:

 It‟s an open source software.

 It has simple and intuitive GUI.

 JMeter can load and performance test many different server types: Web - HTTP, HTTPS, SOAP,

 Database via JDBC, LDAP, JMS, Mail - POP3

 It is platform-independent tool. On Linux/Unix, JMeter can be invoked by clicking on JMeter shell


script.

 On Windows it can be invoked by starting the jmeter.bat file.


 It has full Swing and lightweight component support (precompiled JAR uses packages
javax.swing .* ).

 JMeter store its test plans in XML format. This means you can generate a test plan using a text
editor.

 It's full multi-threading framework allows concurrent sampling by many threads and simultaneous
sampling of different functions by separate thread groups.

 It is highly extensible.

 Can also be used to perform automated and functional testing of your application.

QUESTION: Explain how JMeter works?

ANSWER: JMeter acts like a group of users sending requests to a target server. It collects response
from target server and other statistics which show the performance of the application or server via
graphs or tables.

QUESTION: What is a Test Plan in JMeter?

ANSWER: A Test Plan defines and provides a layout of how and what to test. For example the web
application as well as the client server application. It can be viewed as a container for running tests.
A complete test plan will consist of one or more elements such as thread groups, logic controllers,
sample-generating controllers, listeners, timers, assertions,

and configuration elements. A test plan must have at least one thread group.

QUESTION: List some of the test plan elements in JMeter.

ANSWER: Following is a list of some of the test plan elements:

 ThreadGroup

 Controllers

 Listeners

 Timers

 Assertions

 Configuration Elements

 Pre-Processor Elements

 Post-Processor Elements

QUESTION: What is distributed load testing? How can it be achieved in JMeter?

ANSWER: Distributed load testing is the process using which multiple systems can be used for
simulating load of large number of users. The reason of using more than one system for load testing
is the limitation of single system to generate large number of threads (users). In JMeter we can do
distributed load testing using the master slave configuration.
QUESTION: How can we reduce the resource requirement in JMeter?

ANSWER: To make the best out of the available resources and in general as a practice, following
practices should be incoroprated in the tests-  Use non-GUI mode: jmeter -n -t test.jmx -l test.jtl

 Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.

Don't use "View Results Tree" or "View Results in Table" listeners during the load test, use them only
during scripting phase to debug your scripts.

 Rather than using lots of similar samplers, use the same sampler in a loop, and use variables (CSV
Data Set) to vary the sample. Or perhaps use the Access Log Sampler. [The Include Controller does
not help here, as it adds all the test elements in the file to the test plan.]

 Don't use functional mode

 Use CSV output rather than XML

 Only save the data that you need

 Use as few Assertions as possible

QUESTION: What is Thread Group?

ANSWER: Thread Group elements are the beg inning points of your test plan. As the name suggests,
the thread group elements control the number of threads JMeter will use during the test.

Thread group elements are the beginning points of any test plan.

 All controllers and samplers must be under a thread group.

 Listeners, may be placed directly under the test plan, in which case they will apply to all the thread
goups.

 The controls for a thread group allow you to:

 Set the number of threads

 Set the ramp-up period

 Set the number of times to execute the test

QUESTION: What are Controllers and its types?

ANSWER: JMeter has two types of Controllers: Samplers Controllers: Samplers allow JMeter to send
specific types of requests to a server. They simulate a user's request for a page from the target
server. For example, you can add a HTTP Request sampler if you need to perform a POST, GET,
DELETE on a HTTP service.

Logical Controllers: Logic Controllers let you control order of processing of Samplers in a Thread.
Logic Controllers can change the order of request coming from any of their child elements. Some
examples are: For

Controller, While Controller, Loop Controller, IF Controller, Run Time Controller, Interleave
Controller, Throughput Controller, Run Once

Controller.
QUESTION: What is Work bench?

ANSWER: The Workbench is simply an area to store test elements while you are in the process of
constructing a test. The Workbench is a sandbox for any test or portion of a test that you are
working on. When you are ready to test what you have designed in the Workbench, you can copy or
move the elements into the Test Plan.

It also contains Non- Test Elements Http mirror sever Http Proxy server {which is not available in the
thread group & Test plan }

QUESTION: What is Configuration element?

ANSWER: A configuration element works closely with a Sampler Configuration elements can be used
to set up defaults and variables for later use by samplers.

Note that these elements are processed at the start of the scope in which they are found, i.e. before
any samplers in the same scope.

Its elements:

 cSV Data Set Config: Used to read lines from a file, and split them into variables.

 HTTP Authorization Manager : You can specify one or more user logins for web pages that are
restricted using server authentication

 Java Request Defaults: You can set default values for Java testing

 HTTP Cookie Manager: The Cookie Manager element has two functions:

o It stores and sends cookies just like a web browser.

o Second, you can manually add a cookie to the Cookie

Manager. However, if you do this, the cookie will be shared by all JMeter threads.

 HTTP Request Defaults: This element lets you set default values that your HTTP Request controllers
use.

 HTTP Header Manager : The Header Manager lets you add or override HTTP request headers

QUESTION: What are Listeners?

ANSWER: Listeners let you view the results of Samplers in the form of tables, graphs, trees or simple
text in some log files. They provide visual access to the data gathered by JMeter about the test cases
as a Sampler component of JMeter is executed.

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

Some of the JMeter Listeners are

 Spline Visualizer
 Aggregate Report

 View Result Tree

 View Result in Table

 Monitor Results

 Distribution Graph

 BeanShell Listener

 Summary Report and so on

QUESTION: What does “contain” and “matches” indicates in the regular expression?

ANSWER: In the regular expression, contains indicates that the regular expression matched at least
some part of the target. While matches means the regular expression matched the whole target. So,
„alphabet‟ is

“matched” by „al.*t.‟

QUESTION: Explain what is timer in JMeter and what are the type’s timer in JMeter?

ANSWER: JMeter thread by default will send requests continuously without any pause. To get a
pause between the request, Timers are used.

Some of the Timers used are:

• Constant Timer

• Gaussian Random Timer

• Synchronizing Timer

QUESTION: Explain what is Assertion in JMeter?

What are the types of assertion?

ANSWER: Assertion helps to verify that your server under test returns the expected results.

Some commonly used Assertion in JMeter are:

• Response Assertion

• Duration Assertion

• Size Assertion

• XML Assertion

• HTML Assertion
QUESTION: Why Performance Testing is performed?

ANSWER: Performance Testing is performed to evaluate application performance under some load
and stress condition. It is generally measured in terms of response time for the user activity. It is
designed to test the whole performance of the system at high load and stress condition.

Example: Customer like to withdraw money from an ATM counter, customer inserts debit or credit
card and wait for the response. If system takes more than 5 min. then according to requirements
system functioning is fail.

Type of Performance Testing:

 Load: analogous to volume testing and determine how application deal with large amount of data.

 Stress: examine application behavior under peak bursts of activity.

 Capacity: measure overall capacity and determine at what time response time become
unacceptable.

QUESTION: What are JMeter Functions

ANSWER: JMeter functions are special values that can populate fields of any Sampler or other
element in a test tree. A function call looks like this:

${__functionName(var1,var2,var3)}

QUESTION: Mention the execution order of Test Elements?

ANSWER: The test plans elements execution order is:

Configuration elements

• Pre-processors

• Timers

• Samplers

• Post-processors

• Assertions

• Listeners

QUESTION: Explain how you can capture the script of the authentication window in JMeter?

ANSWER: Normally, you can capture script by recording

 First you have to Thread group in Test plan and then make HTTPProxyServer in Workbench

 After that, set port number in Global Setting box (e.g., 8911) and modify your connection setting in
IE as local host in address 8911 as in port Then you can start http proxy server in JMeter and run
your application for login

Jmeter Short guide

Jmeter
Jmeter is an open source tool for performance testing, even we can use it for regression testing as
we.

It is java based tool and can be used only for web and client server application.

We have by default, Test Plan and Workbench

Workbench work as a temporary storage, it does not save with test plan as well. We need to save it
separately.

Test Plan: (Test Plan is behave like a Test Suite)

In Jmeter test plan can be defined as the group of thread groups and each thread groups behave like
a test case, and a test case(thread group) have steps(elements or samplers) that we need to perform
for a specific scenario.

A test plan can have any number of thread groups.

In test plan we can select check box to “Run thread group consecutively”

Means if we have number of thread groups so only 1 thread group will execute at a time otherwise
all thread groups will execute together.

In test plan we can select check box to “Functional Test Mode”

If we set this, Jmeter will record response of each request sent to server.

This is used when we are in functional testing.

It takes time so it degrade performance.

We can create variable here that can be used throughout Jmeter testing.

Thread Group: ( Thread group is behave like a test case)

First element which is added to test plan is a thread group.

Thread group is use to set number of threads that we execute(Thread can be defined as a virtual
user)

We can set number of time that test case(thread group will execute)

We can set Ramp up time, means in what time all threads will put on application.

We can set Scheduler

Here we can set start time, end time for starting that thread group.

Delay: if we set delay it will override start time value

Duration: If we set duration it will override End time value


Controllers

Controllers drives the processing of the test.

Controllers can be defined as of two types,

Samplers

Samplers are used to send request to the server

Eg: Http request sampler : It is used to send http request to server.

Logic Controllers

With the help of login controller we can let Jmeter in which order request need to be send to server
otherwise requests are processed in the order in which they are added to test plan.

Assertions

Assertions are used to make validations on the response received against to the samplers we used.

Pre Processors

It is used to perform some action, if pre-processor is added to any samplers then its used to
configure settings for samples. So it will execute before samples.

Post Processors

It is used to perform action, if post-processor is added after sampler, it will execute after samples, It
is used to process response.

Config Elements

Config elements are used to set configuration for samplers. It itself does not send any request to
server.

Listeners

Listeners are used to display result.


Timers

Timers are used to set delay

Orders in which elements will execute

Configuration Elements

Pre Processors

Timers

Samplers

Post Processors

Assertions

Listeners

Recording in Jmeter

In Jemter, we can do recording by setting a proxy sever for that we need to follow few steps.

Step 1: Go to the WorkBench

Step 2: Right Click->Add->Non Test Element->Http Proxy server

Step 3: Select Proxy Server, Right click , Addà Logic Controllerà Recording Conroller

Step 4: Select added proxy sever, added in step 2, Select Target Controller is Recording Controller

Step 5: Set Proxy setting in browser, following setting is for mozilla

Tools-Options-Advance

OK

Step 6: Everything is set now. Go to Workbench-> Proxy server and click on Start.

Step 7: Recording is started now, perform actions which you can perform on application using
mozilla, it will record all actions took place between client and server.

Step 8: to stop recording, click on Stop Button.

Now we need to save this separately, because workbench does not save with Test Plan.

Right click on proxy serverà Save as test plan.

Next time we can use it as our test plan.

Before running any test plan, go to Runà Clear. It will clear all previous reports before generating
new report with new data.

Working with Basic Test Plan

What we will do in that,

1à We will create a thread with 5 users.


2à Users will got o website www.learnsoftwaretesting.webs.com

3à Will go to 3 different pages.

4-> We will see report for that, aggregate report, aggregate graph, summary report.

1-> Open a new test plan, create a thread, set number of users is 5.

2-> Add a Configuration element “Http Request Defaults”

This configuration element is mainly used when we are going to perform all action in same web
application, so that base URL will same, here in this config element we need to give only base URL
and in all remaining https samplers for different pages, we will give just relative path to this config
element.

3-> Now create http request for different pages, for that I need to create samplers for http request.

Now in these newly added http request we need not to add complete path or server name.

In path field we will give just relative path of existing path which is set to “Http Request Default”

4-> Now we need to view results, for that we need to add listeners.

We have lot of type of listeners, here we will demonstrate only 4 types

1->Simple Data Writer

Simple Data Writer is use to save response from server in the form of XML(.jtl is extention) or in
(.CSV) format

We can click on configure to select data which we want to save, give file name and click on Done.

It does not display that data, it just save data in form of file.

2àAggregate Report.

It will display all samplers(http requests) in the form of table and display data of each and every
sample(request)

Thoughput : Request per second

3àAggregate Graph.

It is similar to Aggregate report, difference is that, it shows data in form of bar graph

4à Summary Report

It is similar to aggregate report, it take less time and space then aggregate report.

Case Study 2: Need to perform Login, Send Email , Logout, and Debug is by using View Result Tree
Listener

For each step we need to save response

Make assertion to check response times, size.

Run Login only 1 time while email send 2 times and log out 1 time.
Apply a constant delay between all requests going to server.

Apply a random delay between emails which is send by 2 times.

1-> Create thread.

2-> Create Http Default.

3-> Create thread for login( I will do recording for that by using workbenchà http proxy serverà
Recording Controller)

4-> To Debug, we can use Debug Sampler.

5-> Send Mail After Login, content and everything will be picked from Csv file.

6-> Log Out.

7-> View Result Tree.

8-> Spline Visualizer

9-> Distributed Graph.

10->Assertion Result.

To Perform This scenario, I started with

1-> Create a Thread (which we have already seen, we need to run it only 1 user and 1 iteration so no
need to set anything, leave it default)

2-> Now I want to record login Action, For this I have used proxy( we have discussed it already)

** Now login is recorded, the problem which stuck me is that, when I am running back this login, it
display all sample pass but I was not able to login

So as per my finding that that samplers are passed because, all request are going to server and
server send response as well(even it was not a correct response but we are getting response so its
getting passed)

** How we can see that after login step we are getting correct screen or not? How to do debug ?

For that I found my own method, I used a Listener-> Save Response to file, after login sampler I
added this listener, so after the complete script ran, I go to bin directory I find saved response, I can
view that response display the correct screen or not.

** How can we compare request and response that we are getting at time of recording are same in
running.

While recording, use Listenerà View Result Tree, after recording here we can see request and
response data for each and every sample. We can copy that data, now while running use same
listener here again we will get request and response

data, we can compare this data with previously saved data.

For data comparison we can use software Beyond Compare

** While running script getting failed, what is the reason for that ?
One most common reason what I found is that, request which goes to server want some cookies
data but cookies data are not available so to use that cookie data we can use, Config Elemenetà Http
Cookie manager, we can add this in thread group it will handle all cookies and send data with further
requests.

** What is HTTP Header Manager ?

Http Header manager, let us to customize information of request header, we can use it with each
sampler, in that case all values in Http header manager will merge and sent as a header of any
sampler(request)

If we are using Http header manager at both Thread level and Sampler level, then sampler lever
entries will go with request.

If any value is empty with sampler level in this case value at thread level will go with sampler.

It is mainly used to create default header.

** What is HTTP Cookie manager ??

Http cookie manager is used to hold to cookie-value that are coming from server, in case of browser,
browser hold this cookie value which is send with every request but in case of Jmeter, we don’t use
browser so we use that cookie manager which hold these values so any request which need cookies
can pick the value from cookie manager

Cookie manager is mainly used with thread level

We can define our own cookies as well

** What is HTTP Cache manager??

Http Cache manager is used to implement browser cache functionality in Jmeter. Like Http Cookie
manager it is also added at the thread level.

cache mainly hold response coming from server, when we make a request again to that server it first
check if the latest value is still exist in cache request will pick that resource from cache, advantage is
that page get load fast and reduce network traffic as well.

** What is Http Authorization Manager??

Http Authorization manager is mainly used when we are going to access restricted pages that need
user authorization before access, that kind of page open a login window. To handle that kind of
pages in Jmeter we used Http Authorization manager.

Logic Controller

Loop Controller :

Loop controller is used to run samplers in number of loops


If we want to perform one or number of request many time, we can use loop controller for that.

We can perform looping by 2 ways,

1-> Set Loop Count in Thread Group : – If we perform this, it will execute all samples in thread group
in loop.

2-> Loop Controller : – By using Loop Controller, we can run 1 or more samplers in loop.

In loop controller, we can add number of samplers as a child of loop controller so only child samplers
will execute in loop.

Simple Controller

Simple controller dos not provide any functionality, it is just used to make script modular, we can
group samplers belogs to a single page in a simple controller.

Recording Controller

Recording Controller is similar to Simple Controller, it does not provide any functionality but it can
be used when we do recording in Jmeter, with the help of this controller we can divide our recording
script according to logic.

Only Once Controller

Only Once Controller is mainly used when we want to execute script only 1 time and all other time it
will bypass script/request places in only once controller.

If we place only once controller in Thread Group, it will make request under only once controller
only 1 time and in other iteration, it will not execute that script.

If we place Only once controller in loop controller, it will excute samples in Only once controller only
1 time and for remaining iteration, it will bypass this.

Random Order Controller

Random Order Controller is similar to Simple controller, all request under random order controller
will be execute at most once but the order in which request will be made will be random.

Timers
Timers are used to put delay in script, it is used to put some Think Time between requests/samplers
which is going to made by user.

Timers processed before each and every samplers in the scope. It means if we have 10
samplers/request in a thread and we placed a timer under thread as well. Then timer will execute
before each of the available 10 request.

If we place multiple timers then all timers will execute before the samplers.

If we want to make delay only between 2 request then we can use timers as a child element of the
request, but again as we know timer execute before the request and if we want to make timer
execute after a particular request then timer need to be placed as a child on next request.

Constant Timer

Constant Timer is used to put a constant delay between requests.

Uniform Random Timer

Uniform Random timer is used to put a random delay between requests

We need to put 2 values in Uniform Random Times

1-> Constant Delay.

2-> Maximum random Delay.

When this Timer will execute then total delay will be Constant Delay + Randomly generated
Value(which is less than max value)

Synchronizing Timer

Synchronizing timers are mainly used when we want to stop threads until a given number of threads
are reached and then release all the thread together to perform a next task.

This timer is used when we want to put load on specific request of test plan.

Assertion

In Jmeter, Checkpoint are called Assertion. Assertions are used to validate response which is coming
from server.

Assertions are mainly used when we are going to perform functional testing using Jmeter.
Assertion execute after sampler, so if assertion is applied in a thread group it will execute after each
and every sampler, if we want to use assertion for a response of particular request then use
assertion as a child element of that sampler.

Duration Assertion

Duration Assertion is used when we want to check that response is coming in specified amount of
time, if response take more time than given time assertion is marked as failed.

We have 3 option while making assertion, if we select

Main Sample Only : Assertion will apply only to parent requests/samplers.

Sub Samples Only : Assertion will apply to both mail sample/request and child sample/request.

Main Sample and Sub Sample L Assertion will apply to both main and child sample/request.

Size Assertion

In Size Assertion we can specify the size of the response in bytes which we are going to get from
server, we can set size is equal to, greater than etc.

To View Assertion Results,

We can use

1-> View Tree Report — Already Discussed.

2-> Assertion Listener –

Assertion listener is mainly used to view Assertion result.

It display sample name along with data show why assertion has been failed.

Distributed Graph Listener

Distributed graph listener is mainly used when we want to display data in the form of bar chart.

It display bar of each and every response that we are getting from server.

DONE…………………………………..HURRAY………………………………………..

USER CASE : = Login


Check Inbox

Send Mail

Check Outbox.

Check Sent Items

Log out

Logic Controller – For Each, IF , Module , Throughput, Transaction

Config Element : Counter, Login Config Element, Random Variable , User Defined Variable.

Timers : Constant Throughput timer

Pre Processor – HTML Parser, HTMP URL re writing modifier , User Parameter

Post Processor – Debug Post Processor, Regular Expression Extractor , Xpath Extractor, Result Ststus
Action handler.

Assertion – Compare, Response ,HTML , Xpath

Listener : Comparison Assertion Visulizer, Spline

If Controller

IF Controller can be used as we use If in other programming language, if condition is satisfied then it
will execute all requests mention under if condition.

Eg IF ${Count}>8 && ${Val}==3

For Each Controller

For Each Controller is mainly used when we want to make loop of sampler on the basis of collection
of input, for each input value it will run all samples of the loop, if any of the input variable value is
null, loop will terminate.

In this we define input variable & “ _ “ and Number

Now _ is an optional entry

As the loop begins, It copies data of input variable to output variable then we can use this variable in
samplers under the for each controller

Module Controller

Module Controller is a very useful component which implement function calling as we do in most of
programming language. In this we create controllers with samplers that we want to use many time
in our test plan

To perform this we can add a new thread group in test plan, paste all reusable controller in newly
created thread group.
Now when we run our script this newly thread group will also run so if we don’t want to run this
thread group automatically only want to use its controllers whenever we want.

For this we can disable this thread group, now concept of Module controller start, in our original test
plan wherever we want to use reusable controllers of disable thread group we can call that
controllers using module controller.

So we can say that Module controller is used to call other controllers

Note : We can not call its parent chain controllers.

Throughput Controller

*** Throughput controller is not used to control the throughput.

Throughput controller is used to control execution of controller, we have 2 modes in it

à Percentage mode – In this controller will execute till the given number of percentage out of total
number of iteration.

à Total Execute – In this controller will execute till the number of total execution is reached.

Per User : Means if we select it, total number of execution will be number of user* This given
number

Transaction Controller

Transaction controller is used to fine out time taken by group of samples to execute.

It is added as individual sample and it shows the time taken by other samplers+ Timers.

It is similar to tranaction points which are used in QTP.

2 Modes

1-> Parent : can be added as a parent of other samplers but it will not save child samplers in CSV, will
display in XML

All child elements will display in View Result Tree but will not display in other samplers.

Constant Throughput Timer

Constant Throughput Timer is mainly used when we want to maintain a constant given
throughput(samples/minute)

If throughput reaches more than the given limit, this timer will apply pause to make it down.

You might also like