API End - EndNotes V1.0
API End - EndNotes V1.0
a. API Basics
9.Detailed QA Sign Off (1 to 8 Steps continues for 3 Sprints for one Project)
An API is a set of codes which allows two or more than two applications to communicate
each other internally or externally and provide a result to end users or to another API.
Example:
You launch Gmail URL on a browser and enter your credentials. If you provide
correct credentials, you should view home page of your account. If you provide
wrong credentials, you will see some error message.
How it happens actually? When we pass credentials, some information is being sent
to Gmail backend through messenger/channel. These credentials information is
validated, and response is sent back to end user through messenger.
API vs Webservice: -
In general, when we speak about APIs, we are likely speaking about web APIs [APIs
that are accessible over the internet].
This is not always the case though. APIs can be exposed through local files (such as
a JAR file in a Java program, .H file in C/C++ programs, etc.) to allow two local
applications to communicate with each other.
This does not require a network as the two applications are communicating within a
single device. (Read Again and be clear this point)
Webservice: A Web service is a way for two machines to communicate with each other
over a network.
A web server running on a computer listens for requests from other computers. When a
request from another computer is received, over a network, the Web service returns the
requested resources.
This resource could be JSON, XML, an HTML file, Images, Audio Files, etc.
It is important to note the requirement of the request being made over a network.
a) You might be wondering to yourself, APIs and Web services sound like the same thing. It’s a way for two
computers to communicate with each other over the internet, right? Well, not quite.
As we mentioned in the section about “What is an API?,” not all APIs are accessible over the internet(a
network), while Web Services must always be accessed through a network. That’s the difference right
there.
1. Register a patient.
2. Login to patient dashboard.
3. Logout from patient dashboard.
4. Retrieve list of patients.
5. Delete a patient record.
6. Book an appointment.
Developers will develop all these functionalities as APIs which will be integrated by back end
and front-end teams. When development of application is completed, you start testing.
Explanation: An API for “Register a patient” will have logic to register a patient and all types of error or warnings if
something goes wrong. You can test status, speed and data accuracy of an API independently.
URI (uniform resource identifier) identifies a resource (text document, image file, etc)
URL (uniform resource locator) is a subset of the URIs that include a network location
URN (uniform resource name) is a subset of URIs that include a name within a given space,
but no location
That is:
GET:
This HTTP method is used to read/retrieve resource representation only. It is called Safe
methods as it cannot modify information. It should retrieve same information for multiple
identical requests until any other API has changed the state of resource. That’s why it is
also called as idempotent method. Response is returned in JSON/XML format.
Status Codes:
404 (Not Found) –> If GET API does not find the requested resource.
A HTTP POST method is used to create a new resource in collection of resources with
a request body passed as a JSON/XML. If resource is created successfully at the end
point, it returns a status code 201(Created) (Not always) and returns response body.
It may return 200 (OK) and 204 (No Content) status code as well based on how it is
created.
POST is not safe method as it is related to data creation. It is also not idempotent
and invoking two identical POST requests will result in two different resources
containing the same information with just different resource ids.
PUT:
An HTTP PUT method is used to primarily update the resource information, but it also
can be used to create a new resource (Depends on API development) if requested
resource is not available.
If PUT request is made to update resource, it should return 200 (OK) and 204 (No
Content) status code. If PUT request is made to create a new resource, it must
return a status code 201(Created).
PUT is not a safe method as it performs data creation and modifications, but it is
idempotent as if we hit the same request again, it operates on same existing
resource. But note here that a PUT request can be made as non-idempotent as well.
DELETE:
PATCH:
All HTTP methods can be categorized in two categories: Safe methods & Unsafe
methods.
Safe methods: -
If an HTTP method does not change/modify the resource information on the server side or
perform read only operation, is called a SAFE HTTP Method
The reason it is called as a safe method as it does not alter resource information and
prevents actual resource state. GET, HEAD and OPTIONS HTTP methods are safe
methods. These methods perform read only operations. POST PUT etc. are unsafe
methods.
Below are most commonly HTTP status codes which you may encounter during API testing.
You should remember meaning of these status code
Developer would document detailed required details using Swagger editor about Any
API and he provides I receive in the form of Swagger url from the developer (with
the help of swagger url I can see the request and expected response and functional
conditions for each API’s (you will learn more next section)
How can we check response for any API for manually and confirm?
We can use postman and based on given parameters we can perform operations and
get the response in postman
Parasoft SOAtest
PostMan
AlertSite API monitoring
In API testing, we send a request to API with the known data and then analysis the
response.
When you have multiple end points for specific application/project .Those end points may
need to be executed in a particular sequence in that process you may need to capture one
API end point response and may need to use next end point .If you miss execution
sequence those may not get execute successfully
Example: Suppose application Authentication/Login endpoint getting generated SessionID
value in response .So this session id should be used for next endpoints then only other
endpoints will get executed so until you execute Authentication/Login endpoint and capture
and reuse in other endpoints so here you should know first call would be
Authentication/Login then only next end point will be executed
Login User-- generating session id--- until I use session id of login request i get bad
Request -400
What are the major challenges faced during API testing Manual (Read well )
A major challenge is providing input values which are very difficult because GUI is
not available.
How to Overcome: Understand very well business conditions and check from where
data can be gathered for API from Developer or From Documentation (Swagger or
any other system is there to find data based on business conditions it varies based
on organization to organization-will be explained by Lead or Manager)
Call sequencing (We can get from the developer or from documentation
Assumptions: -
1. Before starting any project, Test plan and Test Strategy would have submitted
Responsibilities:
- understanding requirements
- writing scenarios for requirements
- executing and reporting bugs
- preparing testing artifacts and submitting them
- attending release and readiness meetings
all these you will be understanding in detail with practical/real time environment how would
be performed as QA
Here all would meet and discuss which all requirements/user stories should be picked for
the current Sprint. Majorly here Product owner guide to the team which user stories are
higher priority and should be taken initially for specific application
QA Activity: Check in meeting where I should get requirements for the current
sprint to understand it. Once meeting done follow step 1
Parameters:
1.Architecture
After analyzing above parameters here from QA side we should provide estimation by
providing QA user stories
Users stories: -
1) We should provide estimations in the form of story points based on step parameters
2) For each one-story point = 8 hours of work
3) Suppose to write feature file/Testcase it is going to take 16 hours so story points for
the user story 1 would be 2 story points we would give
4) So according to our user stories and time which will take for us we would provide
story points in sprint planning meeting
Day 2
Scrum meeting- Scrum master, Developers team, QA Team all will be involved and
discussed each status, Progress ,About blockers in work .It’s daily call which happens for
15 min
Scenario’s:
We should have Request Body for each Endpoint url to write scenario’s
Let assume end points which are getting developed for the current sprint
“Country” : “ ” -String*
},
“H.No” : “ “, - String
“Street” : “ “ , - String
“Pin” : “” - String*
},
“apprequiredUsername”: “ “, -String*
“password”: “” -String*
Business Conditions: -
1) If you are passing Address Details optional object…if you mention address details you
have to pass pin
2) Gender field accepts only Male or Female Strings
- We should write all scenario’s which should cover complete functionality for
Any API
- Scenario 1: Happy Path - With valid data and complete request (Mandatory+
Optional Objects & Fields)
- Scenario 2: Happy Path – with valid data and only mandatory data (Only
mandatory request)
- Scenario 3: With business validations gender field and address fields
conditions
Manual Testcases for Manual Testing: - (If only manual testing applies)
If we are going to perform only manual testing for API’s we need to write manual
testcases for A the given Endpoint as mentioned below for each endpoint before code
deployed into server. So that once code is deployed into server
Pease find Testcases for one end point for considering online shopping registration end point
APITestcases_Onlin
eShopping.xlsx
Scenario’s for Automation: - (IF only Automation applies we don’t need to write
Testcases ,BDD Scenarios are enough)
1) Scenario : Given register User When user requested to register with all fields Then
receive Success response
Given RegisterUserAPIPath
And Header content-Type = ‘application/json’
And header channelId = “Online_MB’
And Request = {give request with mandatory + Optional data)}
When method POST
Then Status 200
And match response.Message = “successfully User created” (this expected
messages will be given by Developers )
2) Scenario: Given registerUser When user requested to register with only mandatory
fields Then receive Success response
Given RegisterUserAPIPath
And Header content-Type = ‘application/json’
And header channelId = “Online_MB’
And Request = {give request Only with Required/mandatory fields data)}
When method POST
Then Status 200
And match response.Message = “successfully User created” (this expected
messages will be given by Developers )
Business validations starts here
3) Scenario: Given register User When user requested to register with invalid gender
string Then receive 400 BadRequest
Given RegisterUserAPIPath
And Header content-Type = ‘application/json’
And header channelId = “Online_MB’
And Request = {give request Only with invalid geneder with some random string)}
When method POST
Then Status 400
And match response.Message = “Invalid geneder please pass male/female” (this
expected messages will be given by Developers )
4) Scenario: Given register User When user requested to register with address details
and invalid pin string Then receive 400 Bad request
Given RegisterUserAPIPath
And Header content-Type = ‘application/json’
And header channelId = “Online_MB’
And Request = {give reqest with invalid pin in address details object)}
When method POST
Then Status 400
And match response.Message = “invaid pin please check pin detials” (this
expected messages will be given by Developers )
5) Scenario: Given register User When user requested to register with address details
and missing pin field in request Then receive 400 bad reuest
Given RegisterUserAPIPath
And Header content-Type = ‘application/json’
And header channelId = “Online_MB’
And Request = {give request with address details object but miss mandatory pin
field)}
When method POST
Then Status 400
And match response.Message = “Please pass pin Field and correct value” (this
expected messages will be given by Developers )
Negative scenarios
6) Scenario: Give register User when user requested to register with missing few
mandatory fields LastName etc Then user should receive 400 bad request
Given RegisterUserAPIPath
Given RegisterUserAPIPath
8) Scenario: Give register User when user requested to register with valid request Then
user should receive 200 success response
Given RegisterUserAPIPath
Day 8 or Day 9:
Deployment steps:
Once code is ready from the developer. He will deploy into servers we would get
deployment emails from the CI /CD Jenkins .So we would ready to start testing
If not deployed into QA environment we would raise JIRA ticket for code deployment
to QA environment, so that Developer will push code to QA environment
7. Which one has the higher priority in Postman? A global variable or a local variable?
In Postman, if two variables have same name (one being local and one being global)
then the higher priority is of the local variable. It will overwrite the global variable.
Status Code
Response Status
Response time
Response Size
Response Headers
Response Cookies
Response Date and Time
Response Session limit
Response Cookies
Response Server
Response type
Go to POSTMAN client and select method which you need to perform -> Go to Body –
> Select RAW > pass JSON and select JSON from the dropdown and paste the payload
script.
JSON starts with curly braces and stores data in the key-value format.
Pass body and hit send button.it will execute and shows response details as I
mentioned in above steps
Which all Automation tools and libraries available in market for API automation
1.Rest Assured Library
2.Karate Framework
3.SOAP UI (Licensed)
RestAssuredLibrary Setup:
We can write code with BDD style and non Bdd Style lets see both to understand
basic
Please observe difference for each method highlighted in Orange color in below screenshot
“ \name\”: \”tammy\”,\n +
“}”;
Let’s give you a brief idea here about how the above-mentioned code operates:
a. As per the above example, there is no method been passed to ‘given ‘. It means there are no specific
preconditions there.
b. There is a ‘get’ method which is being passed to ‘when‘and it signifies that when we are hitting this URL present
in the ‘get’ method, an event occurs.
c. When we hit the URL in ‘when’, ‘then‘we are going to receive output as a response, and then we perform
validation on it. Here in this particular example shown in the above image, we are performing an assertion on the
body by validating the size of a specified element.
//Adding URI
request.baseUri("https://restful-booker.herokuapp.com/booking");
More Automation code will be updated in next version in 2 to 3 days and will be given
to all candidates
Yet To add
Code for above BDD scenario’s which we are written
How to validate huge response will be covered here
Check Database validation as well (user creation happening or not)
Data tables
Hooks in depth
Upload files in API testing
Interview Tips and Questions and Answers
Important Note If you have DB access while testing, log into Database you can
check created record is present or not in the Database respective table or not (If
you need DB credentials and Database table details, please check with your lead
for DB access
If there are some scenarios suppose one request response need to use input for next
request (refer below video)
Once you test thoroughly above scenarios with post man if you find any Bugs. Create
/Raise Bug in Jira tool
- You need to have JIRA access from the organization you would get check with
lead
- Get access for the project which you are working check with les for the project
access for you
1.Select the Create button at the top of the page (outlined by a red box below).
This will bring up the form to create an issue
c) Minor - Can wait until blocker and critical issues are adder
Fill out the form and hit the create button. JIRA should generate an issue name linked to a
summary of the created ticket:
If any of the fields need to be changed, the Edit button in the upper left hand corner of the
ticket will open an Edit Issue form with access to all of the fields.
The issue should be visible in both the Work and Plan views of the Scrum board under Agile
> <Project Name> Scrum Board or by searching for the ticket's name in the search bar.
Execution reports also should be uploaded under each user story which you performed
testing for future reference
We will list out list of End points and list of user stories which are automated for the current
sprint .We will create in form of one PPT
Sprint Review meeting: In sprint review meeting Automation tasks we could show what
we have done for the current sprint as we create PPT/Created list once testing done
https://strongqa.com/qa-portal/testing-docs-templates/test-report
The thumb rule for the length of a sprint retrospective meeting is that it usually take no
more than 45 minutes per week of sprint duration. The following table illustrates this rule:
1 week 45 minutes
2 weeks 90 minutes (1.5 hours)
3 weeks 135 minutes (2.25 hours)
4 weeks 180 minutes (3 hours)
Suppose 3 weeks sprint then sprint retrospective should happen ideally 2.25 hours by
discussing what went well, what not went well, how can we do better
We should have for release and readiness these below testing artifacts
Release and readiness Document -by mentioning Number of Opened Bugs, Requirements,
End points list as together in one document. (below created sample document)
Below Endpoints for one application are got developed in first 5 sprints and we have written
Testcases (for manual testing), Scenarios (Automation)
1- /RegisterUser
2- /LoginUser
3- /searchProduct
4- /FileterProduct
5- /addtoCart
6- /applyOfferCode
7- /PlaceOrder
So above endpoints are completed, and Business /Client has decided to release this
functionality to production environment 5 sprints
1 We should create release and readiness documents for the above all endpoint’s
requirements. Please check below tables which we should have ready for release and
readiness
Project Info
Project ID
Project Name
Release Version
QA Information
Here we should attach Automation execution report for all endpoints and requirements
which are going to Live
Once we have Testing artifacts these should be get reviewed by Test Coordinator (for
multiple projects one co Ordinator will be there in few organizations)
If there is no test CoOrdinator we should ask manager to review once before we go for
release and readiness meeting.
Once we submit testing artifacts and got reviewed by manager/Test co Ordinator QA Sign
Off is Done
You can provide your details in Release and readiness meeting regarding any open bugs
how those impacts if application goes into live
1. Few major questions are covered from 1 to 5th Page (very important)
2. API testing process from 6th page to 17th Page (you will be able to answer any real time
process)
3. What is Query parameter and what is path parameters in RestAPI? (Read well)
For example, In case, if we need to filter out the students based on their class or
section, we are going to use ‘Query Parameter’. (GET /students?class=9§ion=B)
Sometimes there is a confusion between the Query Parameter and URI Parameter (or
Path Parameter). ‘Path Parameter’ is basically used to identify a specific resource.
For example, In case, if we need to identify a student based on his/her rollNumber, we are
going to use ‘Path Parameter’.
GET /student/{rollNumber}
4. API vs UI Testing
If you have API testing, you don’t need UI testing, right? Don’t say yes
Then if you have UI testing, you don’t need API testing? Don’t say yes
- First, test as much as you can with API testing. Take a look at all of your
possible endpoints and create a suite of tests for each. Be sure to test both the
happy path and the possible error paths. On every test, assert that you are
getting the correct response codes
- Once you have tested all the scenarios you can think of with API testing, then it’s
time to think about UI testing.
UI Testing:
- For example, if you are testing an address book, the most likely scenario for a
user would be adding in a new address. You could create a UI test that would
navigate to the address book, click a button to add a new address, add the
address, save it, and then search the address book to verify that it has been
saved.
Conclusion: Once you have tests that verify all the important elements on your page,
you can stop writing UI tests. It’s not necessary to create lots of scenarios where each
field is validated for various incorrect entries, because a) you already created those
scenarios in your API tests, and b) you already have one UI test that verifies that the
error message is displayed.
The server response holds information which leads a client to perform the caching. It
helps the client to decide how long to archive the response or not to store it at all.
IF your service is Synchronous call you might need to keep on checking for every 5 to 1
0 seconds for response code by automation code
As we raise bug with detail screenshot and reproducible steps, Still after providing the details if he is
not accepting and not able to reproduce from his side
Then…we need to record one video in a webex or with screen recorder reproducible steps and give path
in bug report so that he will go and check (UI Selenium Testing Question)