Showing posts with label JMeter. Show all posts
Showing posts with label JMeter. Show all posts

Friday, 22 April 2016

How to make and run Test plan in JMeter ?


1. Create Thread group
Right click "Test plan"; Choose Add - Threads (Users) - Thread Group
Provide :
 Any name; No. of Threads (Users)=1 [ It could be set as per requirement of concurrent user access ]
 Ramp-up period (in sec.)=30; Loop count=1


2. Create HTTP request under Thread group
Right click Thread Group; Choose Add - Sampler - HTTP request
Provide :
 Any name; Server or IP=(application host); Port=8080; Protocol=http; Method=GET
 Path=(application path) Example: myApplication/myServlet
  CHECK Follow Redirects; CHECK Use keepAlive; CHECK Retrieve all embedded resources from HTML;
 CHECK Use concurrent pool. size=4

a. Add session management (Cookie handling)
Right click HTTP request; Choose Add - Config element - HTTP cookie manager
Provide any name

b. Add headers to the HTTP request (If application is expecting some request headers)
Right click HTTP request; Choose Add - Config element - HTTP header manager
Provide :
  Any name
  Header stored = Provide request headers in key/value pairs.

c. Add Authorization parameters to the HTTP request (if application using browser authorization)
Right click HTTP request; Choose Add - Config element - HTTP Authorization Manager
Provide :
  Any name; Authorization stored = provide username and password


3. View results
View results in table
Right click "Test plan"; Choose Add - Listener - View Results in Table

View results tree
Right click "Test plan"; Choose Add - Listener - View Results Tree

Aggregate report
Right click "Test plan"; Choose Add - Listener - Aggregate Report
Aggregate Graph
Right click "Test plan"; Choose Add - Listener - Aggregate Graph


4. Run test
Choose Test plan and click Run icon (Ctrl + R)
View test result in added listener.

How to record the test using Recording controller and Proxy server ?


1. Add Recording controller
Right click "Test plan"; Choose Add - Threads (Users) - Thread Group
Right click Thread Group; Choose Add - Logic Controller - Recording Controller


2. Add Cookie manager in Recording controller
Right click Recording controller; Choose Add - Config element - HTTP cookie manager
Right click Recording controller; Choose Add - Config element - HTTP header manager.


3. Add HTTP Proxy server
Right click on WorkBench; Choose Add - Non-test elements - Http Proxy Server
On HTTP Proxy Server, provide :
 - Port : Port for capturing recording  (example : 8081)
 - Add following entries in "URL Patterns to Exclude" using Add button :
  *.gif
  *.jpg
  *.png
  *.ico
  *.jsp


4. Configure your browser (skip this step, if already configured)
Start browser (usually, Firefox). Go to Advanced - Network - Settings - Manual proxy configuration
Set host=localhost, Port=8081 and Check "Use this proxy server for all protocols"

For IE, Go to Tools - Internet options - Connections - LAN Setting - proxy server
Set Address=localhost, Port=8081 and Check "Use a proxy server"

Here, the port should be same as given in HTTP Proxy Server of workbench.


5. Start recording
Select HTTP Proxy Server.
In global setting, ensure that the port given should be same as provided in proxy configuration in browser.
Choose target controller (where to record) "Thread Group - Recording controller" and click the "Start" button.
Open application in browser and perform steps.
To finish the recording, click Stop button in HTTP Proxy Server.
Expand the Recording controller. There would be several samplers / HTTP request.


6. Add listeners to Thread group to view result
Right click Thread group; Choose Add - Listener - (choose any listener)
Click Thread group and provide Number of threads (users) and Ramp-up period.
Run the test plan and check result.