[go: up one dir, main page]

0% found this document useful (0 votes)
90 views25 pages

APITesting Session Final

Uploaded by

Sunil Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views25 pages

APITesting Session Final

Uploaded by

Sunil Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

【 NEC Group Internal Use Only 】

Introduction to API Testing


Presented By:
Priyanka Saxena

© NEC Corporation 2023 NEC Group Internal Use Only


Agenda
 Basics of API
 What is API Testing? Why it is needed?
 Types of an API – SOAP & REST
 API vs Webservice
 Types of Bugs
 Popular Tools
 REST API methods
 Components of API- URI,Endpoint, Payload
 Decoding Response Codes
 Postman Basics
 Newman
 Queries
What is an API

Application Program Interface(API): Is the way of communication between 2 applications where applications
may differ in their platforms or in terms of technology

4 © NEC Corporation 2023 NEC Group Internal Use Only


What is a webservice?

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.

5 © NEC Corporation 2023 NEC Group Internal Use Only


Types of Web Services

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.

6 © NEC Corporation 2023 NEC Group Internal Use Only


Why test APIs?

7 © NEC Corporation 2023 NEC Group Internal Use Only


API Testing

8 © NEC Corporation 2023 NEC Group Internal Use Only


API Testing Types

9 © NEC Corporation 2023 NEC Group Internal Use Only


10 © NEC Corporation 2023 NEC Group Internal Use Only
Types of Bugs

11 © NEC Corporation 2023 NEC Group Internal Use Only


12 © NEC Corporation 2023 NEC Group Internal Use Only
13 © NEC Corporation 2023 NEC Group Internal Use Only
Understanding REST API Components
Swagger- A suite of tools for API Developers from Smart Bear Software. It helps users build, document, test and consume
RESTful web services.

14 © NEC Corporation 2023 NEC Group Internal Use Only


Understanding REST API Components

15 © NEC Corporation 2023 NEC Group Internal Use Only


Breakdown of REST API Components

16 © NEC Corporation 2023 NEC Group Internal Use Only


REST API Methods

Another API method HTTP PATCH:


HTTP PATCH requests are to make a partial update on a resource.
PATCH method is the correct choice for partially updating an existing
resource, and you should only use PUT if you’re replacing a resource in
its entirety.

 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.

17 © NEC Corporation 2023 NEC Group Internal Use Only


Decoding Response Codes

18 © NEC Corporation 2023 NEC Group Internal Use Only


Automating API Tests

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.

Using Postman Tool


Postman is one of the most popular software testing tools which is used for API testing. With the help of this tool,
developers can easily create, test, share, and document APIs.

19 © NEC Corporation 2023 NEC Group Internal Use Only


Automating through Postman

Step1:
Setup Postman
• Create a new collection

Step2:
Setting up Postman Environments
• This will help you quickly switch your testing between different working
environments

20 © NEC Corporation 2023 NEC Group Internal Use Only


Automating through Postman

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

21 © NEC Corporation 2023 NEC Group Internal Use Only


Automating through Postman

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

22 © NEC Corporation 2023 NEC Group Internal Use Only


Automated Tests Execution

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.

23 © NEC Corporation 2023 NEC Group Internal Use Only


Newman

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.

24 © NEC Corporation 2023 NEC Group Internal Use Only


Queries

25 © NEC Corporation 2023 NEC Group Internal Use Only

You might also like