PracticesToolsTutorial

API Testing Using Postman: Part 1 (What is an API?)

In this video Promode of the Testing Academy explains how API testing is performed using Postman.

In this video Promode of the Testing Academy explains how API testing is performed using Postman.

1:07 He highlights that the have been running lots of different test cases using selenium grid, docker, swarm as well as right now we are moving to Kubernetes.

Overview of Tutorial

From 01:39 he started to give the overview of the process that we are going to learn in this video series. As, per him it will help those seeking career in software testing. API testing is important if you are a software tester, you want to increase any kind of domain it will provide push to your career to excel in expertise especially in API testing.

At 02:05 he talks about certain HTTP methods where we will learn how one can do certain request in postman especially using GET, PUT, POST and how as an enterprise-level we are doing in the industry standard. Usage of tools like Postman & the Newman are used for testing on different docker grids. He further talks about bugs encountered in testing and difference between SOAP and REST API.

What is API?

At 03:34 he explains API which is abbreviation of Application Programming Interface. He started off with an example that you go to a restaurant and API is basically a waiter that takes your order and tells the chef in the kitchen what exactly food needs to be prepared. In this example waiter is an API which is acting as an interface between two software applications.

Types of API & its testing importance

At 04:53 he explains that there are various types of API. First one is SOAP, then JSON RPC, XML RPC and then REST. Problem in any API is vital from client-side as it will have major impact. It is always mandatory to check about it’s the integration and its services.

Sometimes developer mistake will create buggy API and to avoid such situation testing is essential. Internet is using millions of API like twitter, slack API, Instagram, and Facebook API so their millions of API requests are going on so they should be tested thoroughly. For its validation testing is important.

At 07:53 he explains that we require that JSON schema, as well as XML schema, should be validated whenever we are testing. He further discussed that keys in API should be validated, performance test should be done to know affects; when API is loaded. While moving on he explains the messaging protocol.

Protocols SOAP & REST

SOAP is the Simple Object Access Protocol used for program communication with servers of any kind. In these servers client sends a request according to this envelope (SOAP XML type of WSDL Web services description language) and server responds back according to this XML based architecture. SOAP uses similar to REST API HTTP methods.

While explaining further he tell us that REST is a representational state transfer. It’s a design pattern of an API. REST architecture basically describe few constraints, we call them a RESTful web services or RESTful web API. There are few differences between SOAP & REST former is basically an XML based messaging protocol, whereas REST is architectural style protocol.

This envelope based it contains certain envelope to send a message, generally it’s not human readable whereas most of the time response coming is in XML or JSON can be easily interpreted by humans.

Generally, as we have mentioned last point SOAP performance is not great compared to REST.SOAP is slow, complex and its envelope based Messaging protocol, so performance is not great whenever we are using SOAP API. In REST performance is much better we are sending payload in JSON and XML. They are not very much CPU extensive.

REST & Its Constraints

At 13:18 he gave example, simple application that you are using in android like Instagram is basically using REST API and fetching any kind of user information, likes, follows whatever it is.

Using REST API, REST is everywhere. But there are some constraints of REST. Starting with Uniform Interface, for example while communicating client sends a JSON request to the server then the server needs to understand it and the server has to send the request into the JSON. They need to agree on it, the interface that we have it should be uniform, that’s what the uniform interface means.

Another constraint is Cacheable, it means whenever the client requests particular user Information, the server can send whether this informational has to be cacheable or not. It aso has constraints which is Client-Server means there will be client, there will be a server there will be like two different entities they can behave independently, they are not like clubbed with each other. An API that follows these type of constraints we call them RESTful API.

Postman Tool & API

At 17:49 he started installing the postman, and starting the demo part. Login to postman.com, click on this Get Started button and download the exe, it’s very simple process you can download whatever version it is, on Mac, it will give option according to Mac. He shows the main menu for Postman tool dashboard.

It is kind of request you are making in postman tool. At 20:05 he explains that it will provide you building blocks where one can create request, create collection like integrated environment so it will give options like documentation, mock server as well as monitoring the API.

Another option is there for creating an API key for authentication if anyone wants to access this collection. Collections are basically flow of requests; simplest example will be like there is user

Users can perform different actions & after getting user id can make some request to certain things like there will be 3-4 requests. What we can do is that we can put all these number of request into a collection and before running a collection you can run these pre-scripts.

Right now the scripts will be in java script, mainly the syntax they are following is java script. This is the main window here, where you have different kinds of methods.

GET method & Postman tool

At 22:30 he started explaining GET method, GET requests are the most common and widely used methods in APIs and websites. It is used to retrieve data from a server at the specified resource. For example, say you have an API with a /users endpoint.

Making a GET request to that endpoint should return a list of all available users. He explains that there are different options in Postman tools and we can change the theme, use different shortcuts. At 24:37 he explains that SSL certification is on by default for this tool. One should switch it off while working in staging environment to avoid SSL errors.

Data can be exported and not required any certification, proxy or updates for this. At 25:54 he talks about different variables for Postman tool which are global or normal variables. Variables allow you to store and reuse values in your requests and scripts.

By storing a value in a variable, you can reference it throughout your collections, environments, and request; and if you need to update the value, you only have to change it in one place. Using variables increases your ability to work efficiently and minimizes the likelihood of error. At 26:26 he concludes his basic demo for postman.

Related Articles

8 Comments

Leave a Reply

Your email address will not be published.

Back to top button