Apache JMeter is an open source tool for performance testing. It is widely also used for functional testing of API services. This course will teach how test Web services (REST/SOAP) using JMeter.
What is JMeter testing?
Apache JMeter is a java open source software that is used as a load testing tool for analyzing and measuring the performance of a variety of web sites. It was originally designed for load testing web applications but has since expanded to other test functions.
JMeter: Apache Jmeter is open source. we can to reduce the cost and we can mimic we can simulate the user, all these features are possible.
Performance Testing:
A type of software testing to ensure software applications that will perform well under their expected workload.
Load Testing:
Load testing is testing to see whether the system or application under test is able to handle the required number of concurrent user accesses on web server without any failure.
Stress Testing
Stress testing is testing to see how the web server cops of with high load and limited resources
Why JMeter:
- Open source
- Java based -platform independent -multiple os
- No programming skills
- HTTP, FTP, SOAP are supported by JMeter
- API web based application
- Reports are visually good
- ANT tools interactive reports.
- Multithreading
- Distributed load testing
- Mimic real time traffic
Installation:
- Check java is installed on your system: java - version
- Download jmeter from internet
- Unzip and keep jmeter folder at any location
- Start jmeter
- Jmeter>Jmeter/bin>Jmeter.bat (or jmeter windows batch file)> click it
How to create first Jmeter Test:
- Start Jmeter
- Create a Test plan
- Create a Thread Group (Users)
- Add a sampler (HTTP)
- Add Listeners
- Run the Test
Note: thread group is the users that will be used to create or run this test.
listeners are the reports
Assertions:
Assertion = check on the Response
Response Assertion
Apache JMeter is an open source tool for performance testing. It is widely also used for functional testing of API services. This course will teach how test Web services (REST/SOAP) using JMeter. JMeter is highly used in comparison tool SOAP UI & Rest Assured library as it is free and no coding skills required.
This course will not teach theory but it is 100% practical, also teaching with Real Live examples, not just some mock API's.
In this course we would be covering below topics, for detail list please check the Curriculum.
- What is API Testing & why we need to do?
- What is JMeter and Installation.
- Jmeter Components for API Testing
- Test Plan
- thread group
- Controllers
- Smaplers
- Listeners
- Assetions
- Scenarios of REST API (GET, POST, PUT, DELETE)
- Scenarios of SOAP Webservice
- Handling CSV Files
- JMeter Function needed for API Testing
- Paramterization
- Authorization
- Real Project Examples and Reporting
What you’ll learn
Implement API Automation Suite in there project.
Implement JMeter for API Testing.
Handling of REST & SOAP API
JMeter components required like Samplers, Listeners, Controllers etc required for API Testing.
Understanding how API testing done with JMeter in real projects.
Popular Assertions in JMeter:
What, why and techniques of performance testing?
About APIs
What is API?
Types of API:
- REST
- SOAP
HTTP commands
- GET
- PUT
- POST
- DELETE
HTTP Proocols
- HTTP
- HTTPS
HTTP error codes
HTTP 401 - Unauthorized access
HTTP 400 - Bad request or request was corrupted
HTTP 403 - Forbidden access (restrict website on company)
HTTP 404 - Requested resource does not exist
HTTP 500 - Internal server error
About JMeter:
What,why, installation of java and JMeter and its features.
Components of JMeter
Thread group, - features, components
Popular Logic controllers:
- Simple controller
- loop controller
- Random controller
Popular Listener
- View Results in table
- View Results in tree
- Aggregate report
- Simple Data writer
HTTP Header Manager
Parameterization
Rest API Handling HTTP methods:
- Authorization
- Post Request
- Put Request
- Delete Request
SOAP API Testing using JMeter:
Difference between REST and SOAP API
Creating Scripts for SOAP API testing using JMeter
Popular JMeter functions:
- _threadNum
- _samplerNmae
- _counter
- Time UUID
- Machine IP/Machine name
Using CSV Data config:
- Read Data using CSV data config file
Handling Assertions:
Real time script - creating test suit using Jmeter and analysing Jmeter test report and report.
What is Performance Testing ?
Performance testing checks the application behavior under different set of loads of users.
Why performance testing ?
Performance testing makes application more robust, makes application more scalable, fast, response time fast, reliable and stable.
Techniques performance testing ?
- Volume testing- testing done with large amount of data, use dummy data
- Load testing - testing done with large amount of user
- Stress testing - testing application beyond its limit. Increasing both data and user to the application.
- Spike testing : suddenly number of users increasing ramp of period
- Soak testing : stress testing long period of time at certain load
API - Application programming interface
API - public and private eg. google API (RESTful) is a public API.
Restful API is famous and SOAP API is complex.
API - functionality and behavior, Integration with API 1 and API 2. API with application.
JMETER:
It helps to stimulate the behavior of real time time traffic of application. It can stimulates the users and see the behavior of the application response utilization the server.
Why JMeter-
Open source, java based -platform independent, multiple os, no programming skills, HTTP,FTP, SOAP are supported, api and web based application, reports visually good, ANT tools interactive reports, JTL files for custom reports, multi threading, distributed load testing, mimic real time traffic.
Installation of Jdk:
Download JDK and install. Then go to enviroment variable and edit path..then put ";" and copy paste bin path of JDK.
Go to cmd and type javac and java -v
Installation of Jmeter:
Download the JMeter.
Go to enviroment variable and copy paste JMeter path . Do new and paste pathe
Ovierview of JMeter:
bin folder - all j meter script. J meter windows Batch file. double click it.
extras file has reporting tools
How do you open JMeter from command prompt:
cd Dev\apache\apache-jmeter-5.2.1\bin
jmeter-server.bat
Thread group components:
Logic controller is use of control the action of request.
Config Elements is used to add the detail of request. eg Authorization, header, cookie
Timer is used to add any delay to the server.
Pre processors eg add parameters
Sampler eg HTTP reuest. stimulation of number of users.
Post processors if you want to any info from response.
Assertions is use for validate the response.
Listener is use for visual results of response.
Creating script for REST API using JMeter :
...................................................................................
Components of JMeter:
creating test case using template: Go to file and add Template: and select Template.
How to import code files in JMeter
1) Copy script(with .jmx extension) for eg. "HTTPRequestForGoogleMaps.jmx".
2) Open apache-jmeter folder.
3) Go to "bin" folder and paste the file in it.
4) Now go to apache-jmeter > bin.
5) Run jmeter.bat file. GUI of JMeter should open up.
6) In menu options, go to File > Open.
7) Browse to the location in step 3, select it and click "Open" button.
8) Script should now be loaded.
Step of JMeter:
- Create the request ( Test plan > Thread group > Sampler: HTTP request)
- Send it to the server
- All the responses are saved
- Information is collected
- Response is returned (listener)
Thread Group:
How much times takes to execute test:
t(number of user) = 20
r(ramp up period) = 100
u(1 user)
r/u = t
100/u = 20
u = 5
For one user it takes 5 seconds and
20 users need 100 seconds.
.................................
loop count 20
Test case: 20 users.
Scenario:
user 1: 1 pm
1. Login to twitter
2. Enter status
3. Logout
user 2: 1:10 pm
1. Login to twitter
2. Enter status
3. Logout
....
....
user 20:
1. Login to twitter
2. Enter status
3. Logout
2 batches of 20 users each - loopcount -2
2 * 20 = 40 users.
Popular JMeter Functions:
${__time(YMD)}
go to tools and function helper you can get a fomat
${__UUID()}
it generates everytime. it is unique identifieer
Machine IP Name:
Helps to run JMeter in different machine.
${__machineIP()}
${__machineName()}
Using CSV Data Config:
- helps to fetch the data from csv file
- helps to parametrize the data
- variables and fetch the values for different keys
Popular Assertion in JMeter:
Helps for validate response result.
Response assertion: text, code,
Duration Assertion: response responds on exception time or not
Assertion results.
size assertion results
XML assertion
Error threshold..how many error you can allow
we can save or store result on text or different format.
.....................
Live project:
changing weather temperature degree Celsius to Fahrenheit.
Ramp up / Threads = time per user
50/20 = 2.5 sec
References:
No comments:
Post a Comment