APITesting Session Final
APITesting Session Final
Application Program Interface(API): Is the way of communication between 2 applications where applications
may differ in their platforms or in terms of technology
A web service is a set of open protocols and standards that allows data to be exchanged between different
applications or systems.
Web services have the advantage of allowing programs developed in different languages to connect with one
another by exchanging data over a web service between clients and servers.
SOAP defines a standard communication protocol (set of rules) REST describes a set of architectural principles by which data can be
specification for XML-based message exchange. SOAP uses transmitted over a standardized interface (such as HTTP)
different transport protocols, like HTTP and SMTP.
Safe Methods: Request methods are considered safe if their defined semantics are essentially read-only. The
client does not request, and does not expect, any state change on the origin server as a result of applying a safe
method to a target resource.
The GET, HEAD, OPTIONS, and TRACE methods are considered safe methods.
Idempotent Methods: Defines an operation that will produce the same results if executed once or multiple
times.In HTTP specification, the PUT, DELETE and safe methods (GET, HEAD, OPTIONS, TRACE) are idempotent
methods.
API Automation: Instead of running your requests manually, then verifying the response, checking data returned, comparing
schema and completing the tasks that follow, you will script it once, prepare it, and then it’s just a matter of clicking a button.
Step1:
Setup Postman
• Create a new collection
Step2:
Setting up Postman Environments
• This will help you quickly switch your testing between different working
environments
Step3:
Create New User Request
• Create request as per the API Specification, could be POST,GET,PUT OR DELETE
Step4:
Collection Variables
• In order to send this request, it will need authorization, instead of manually
copying the token every time during every request, it’s best to use collection
variables to store the token
Step5:
Verifying Response and Writing Tests
• Every API Request would send a response which needs to be validated to
ascertain the request passed or failed. This verification can be done in Postman
by writing few lines of code in ‘Tests’
Step6:
Success Result in Postman
• Test Results in Console will display whether the API status code was 201 or error
was returned from server. You don’t need to look into the response, it’s
automatically verified on behalf of you
Postman provides a built-in feature called Collection Runner, which provides you with the ability to run a specific
collection right away from Postman.
Click Run collection, and once finished all the requests inside the collection will run along with the Tests included
in each request:
In case of errors or failed cases, you will see them highlighted in red.
There is another option, which is a CLI tool called ‘Newman’ developed by Postman. It provides you with the ability to run
your collection from the CLI, whether it’s on a CI/CD pipeline remotely, or locally using your CLI.
Newman will start reading your collection, execute all the requests, and verify all the test cases inside.