API is Application Programming Interface. It is used to establish communication and data exchange between two software systems. A software system implementing an API consists of various functions and sub-routines which can be executed by another software system. API testing is totally different from GUI testing. It basically concentrates on the business logic layer of the software architecture. In API Testing, you use software to send calls to the API, get output, and note down the system's response.

API Architecture

API calls collection includes mainly two things:

1. HTTP headers: HTTP headers are always dependent on your application.

i) Authorization: A token included with requests to identify the requester. This header has to be included in all requests other than the login request.

ii) Content-Type: A standard MIME type describes the format of object data.
Content type in most of the requests and responses will be application/json.

2. HTTP Request: There are mainly four types of requests.

i) POST– Used to Create or Update data

ii) PUT- Used to Update data

iii) GET- Used to Retrieve data

iv) DELETE– Used to Delete data

What is Postman?

Postman is used to fire requests to an API. It is available as add-in on Chrome and also available for Mac application.  It is very fast in response and also light weight which puts no impact on browser performance. Tests can be created with verifications for certain conditions on the response. With Postman, you can create different kinds of HTTP requests such as GET, POST, PUT, PATCH and DELETE. It also provides supports for adding headers in the requests. It’s a very convenient API tool with very useful features.

How To Perform Automation Testing of APIs Using Postman?

Following criteria detailing the process, to perform automation software testing of APIs by using Postman:

* First, install ‘POSTMAN’ add on in Google Chrome.

* Open Postman.

* Click on ‘Create New Collection’ button, fill details and Click ‘Create’ button.

* Now go to newly created Collection and Create New Folder by selecting ‘Add Folder’ option of side menu bar.

* Now Click ‘+’ Button for opening new Tab.

* Now Fill URL, headers, Select Method (Get/POST/PATCH etc.), Body etc. and click ‘Send’. It will show the result in a response. It should return desired results. If there is a problem Please recheck every prerequisites and requirement.

* You can add desired assertions in a particular request in tests tab like:

           tests[“Check: Status code is 201”] = responseCode.code === 201;

* Now ‘Save as’ request by filling its Name, Folder Name, Description etc. It will show the request under your selected Folder/Collection.

* Now Click on Setting Environment Button (Setting Icon on Top right corner under Heart Icon) and select ‘Manage Environments’.

* Click on ‘Add’ Button, Enter Name for environments, Enter Keys and Values. Keys(Name of the variable like URL), Value(Value of Variable like: http://bugraptors.com/). Click ‘Add’. It will create environments.

* Now select newly created environments from DDL (Top right corner with setting Icon).

* Now use the variable as a requirement. Syntax to use is {{Key of variable}}.Like: {{URL}}. It will show variables in a list and you can select from there too. If the variable is accessible it will automatically convert it into orange color either it will reflect in Red color.

* Do the same process for all your APIs.

* Now you can run the whole collection or single folder by Clicking on ‘Runner’ (Top Left corner Button) or Click run from the submenu of the desired collection. It will open Runner Window. Select Collection/Folder, Select required environments, Fill iteration count (If you want to run it multiple times), Fill Delay, Choose Data File if required, and click ‘Start Test’. It will Give you result of every request.

* You can fetch Data from the response of a particular request and store that in variables. The syntax of it is like:

           var jsonData = JSON.parse(responseBody);

           postman.setEnvironmentVariable(“variable_key”, “variable_value”);

* For ‘report’ you have to install ‘Newman’ on your PC. It is command line tool that can generate the report by running POSTMAN collections.

* Now export Postman Collection by selecting Export from the left menu bar of the desired collection.

* Also, export the required environments on manage environments window from download icon button.

author_image

Achal Sharma

Achal is a seasoned Mobile Automation Lead in BugRaptors with an ISTQB certification, possessing extensive expertise in mobile automation testing. With a robust background in developing and implementing automation frameworks tailored specifically for mobile applications, Achal excels in ensuring the quality and reliability of mobile software products. His proficiency in utilizing cutting-edge automation tools and methodologies enables him to streamline testing processes and accelerate release cycles. Achal's leadership skills, coupled with his commitment to delivering high-quality solutions, make him a valuable asset in driving mobile automation initiatives and achieving organizational goals effectively.

Comments

Add a comment

BugRaptors is one of the best software testing companies headquartered in India and the US, which is committed to catering to the diverse QA needs of any business. We are one of the fastest-growing QA companies; striving to deliver technology-oriented QA services, worldwide. BugRaptors is a team of 200+ ISTQB-certified testers, along with ISO 9001:2018 and ISO 27001 certifications.

USA Flag

Corporate Office - USA

5858 Horton Street, Suite 101, Emeryville, CA 94608, United States

Phone Icon +1 (510) 371-9104
USA Flag

Test Labs - India

2nd Floor, C-136, Industrial Area, Phase - 8, Mohali -160071, Punjab, India

Phone Icon +91 77173-00289
USA Flag

Corporate Office - India

52, First Floor, Sec-71, Mohali, PB 160071,India

USA Flag

United Kingdom

97 Hackney Rd London E2 8ET

USA Flag

Australia

Suite 4004, 11 Hassal St Parramatta NSW 2150

USA Flag

UAE

Meydan Grandstand, 6th floor, Meydan Road, Nad Al Sheba, Dubai, U.A.E