API testing - how to use Postman in everyday QA work?

Choosing the right and most suitable API type has an invaluable influence on the business strategy. You should decide whether you would like to build your own infrastructure or rely on third-party providers. Both solutions have their own benefits and disadvantages, but let me leave them aside and let’s imagine you’ve already chosen your perfect API. Why should you also focus on API testing?

Why should you test API? 

At first glance, API testing may seem an additional and unnecessary effort and cost, but the truth is that taking this step speeds up the whole software development process due to quick detection of many issues. API tests bring lots of benefits and omitting them can cost you a lot. Quality Assurance team can’t wait for the end of mobile app development to test it, so the API testing should be implemented as soon as possible. Why is it so important? Because fixing bugs is not a cheap thing and the sooner the bugs are detected, the less effort and costs it will take to repair it. To ensure the best environment for testing you should take care of the good communication between testers and software developers. But that’s only the first step, software Quality Assurance specialists should also be provided with the appropriate tool to improve the API testing and Postman seems to be the most relevant. 

Why choose Postman for API testing?

Postman consists of tools that allow you to create your API, and, what’s also important, provides you with lots of testing possibilities. Here I listed some of its most important functionalities: 

  • sending requests to the API,
  • creating a query collection,
  • has the ability to write tests in JavaScript,
  • handling multiple environments. 

Postman has a clear and user-friendly interface thanks to which it is quick, intuitive and available not only for software testers but also for project managers. PMs can gain a better understanding of the team workflow and API documentation by using it and also raise their technical skills. What also speaks in favor of this tool is the fact that in its basic plan it’s free of charge with almost all of its features available. And now let's leave the theory aside and focus on more technical stuff. I’m going to show you, how to install Postman and start working with this tool. 

Before start working with Postman

Postman is available as a browser plugin and a desktop application. I recommend to chose App because it has more functionalities available. After installing Postman, the next step you should take is to create an account and then log in. The application interface consists of:

  • side menu that allows you to create collections, in which we can store previously created queries,
  • main screen, where we can choose the method HTTP from the dropdown menu, bar to enter url address, parameter settings in the section under address bar and Send, Save buttons,
  • top menu, in which there are several additional options.

As you can see at this step, my former claims about its simple interface were not an exaggeration - Postman is really clear and intuitive tool. So, let’s go ahead and focus on some of its functionalities. 

Sending a query

Postman gives us many methods of creating queries, but here are some often used:

  • GET-method allows you to download the entire resource;
  • POST - this method allows you to create a new resource;
  • PUT - is similar to the POST method, it also sends data to the server, but additionally edits those resource data that have changed;
  • PATCH - method is used for editing individual resource data;
  • DELETE - delete resource.

In order to perform the GET method, I’m going to use REST API (JSONPlaceholder) which will return a list of all posts. First, you should add a new query using the "New" button and then choose the method from the dropdown menu. The corresponding endpoint is entered in the address bar, where the request will be sent.
 
After sending a request to the indicated endpoint, an answer from server will be displayed at the bottom of the main screen and additional information such as cookies, headers, response status, duration or size. When creating a new request, the Query Params section also gives you a possibility of sending parameters, where these parameters are defined as a key-value. Example:

postman-merixstudio-apitesting

Ability to save created queries, as a collection is a particularly useful functionality in Postman. This form of query storage is very transparent, and finding and using a specific query again is not a problem in Postman. New collections are created using the "+ New Collection" button and, together with previously created collections are visible from the left window pages. In the collection itself, you can not only add subsequent requests but group them into separate folders. In a situation where a larger number of people work on a project, a great advantage is that we can share requests among themselves, as well as export.

postman-apitesting

Environments and variable

Another useful Postman functionality is that you can test endpoints on several environments e.g. test or production. It’s enough to define environments and variables in "manage environments" tab. 
When defining a variable, you must enter three values: 

  • name variable, 
  • initial variable, 
  • current variable. 

The same variable with different value can be used in a query for many environments. Thanks to this, you do not need to modify request many times.

postman-apitesting

In order to use this variable, select environment that interests you from the dropdown menu and then enter the name of the variable in double brackets {{variable name}} in the request. This way, you can define many variables in the environment area, which will then be used in the query.

Postman automating

As you may have already noticed, every repetitive task can be replaced by a script. Postman implemented runtime based on Node.js. So if you are familiar with server-side JavaScript, you can save even more time.

I hope that after reading this article you have no doubts that API testing is not only a significant and important part of the software development process but also conducting them is as easy as pie. Thanks to tools such as Postman bug detection at the early phase of the quality assurance process is much easier and, as a result, the costs are reduced. Not only the fact that Postman is available for free but above all, a number of useful functionalities that speed up the API testing process make it a tool that is worth using in every project.

Navigate the changing IT landscape

Some highlighted content that we want to draw attention to to link to our other resources. It usually contains a link .