avatarDmitry Yarygin

Summary

This article provides a quick guide for test engineers on how to perform API testing using Postman, a popular tool for making API requests and testing the responses.

Abstract

The article titled "Quick Guide: API Testing for Test Engineers using Postman" is a tutorial designed to introduce QA Engineers to the process of REST API testing. It outlines the necessary tools, such as Postman, and the steps required to perform API queries, including setting up an account, creating a collection, and sending a request to an API endpoint. The guide demonstrates how to interpret responses, adjust request parameters, and utilize the "Authorization" tab for API keys. It also covers writing tests and performing assertions within Postman to verify the status code and response content, emphasizing the importance of these skills in modern application testing. The article concludes by highlighting the power and versatility of Postman for both sending API requests and running test scripts to ensure backend correctness.

Opinions

  • The author suggests that API testing is a crucial skill for modern QA Engineers, bridging the gap between manual and automated testing.
  • Postman is recommended as a user-friendly tool for performing API queries and testing, with both desktop and web versions available.
  • The guide emphasizes the practicality of API testing in verifying backend functionality and ensuring that applications work as expected across different environments.
  • The article implies that understanding how to adjust API requests and interpret responses is essential for effective API testing.
  • The inclusion of test script examples and the mention of Postman's built-in test snippets indicates the author's view that these resources are valuable for learning and implementing API test assertions.
  • The conclusion reinforces the idea that mastery of API testing tools like Postman can significantly enhance a QA Engineer's ability to quickly check the status of backend services.

Quick Guide: API Testing for Test Engineers using Postman

Photo by David Pupaza on Unsplash

When we talk about performing testing — there is typically a wide range of activities a typical QA Engineer performs those days.

It could be: - Testing the new build - Verifying the backward compatibility with older app versions - Making sure that the build works correctly against different environments - Writing Test Automation scripts

And there is also one type of activity that falls between multiple categories. It’s not exactly manual testing and it’s not automation testing either. This is what’s typically called REST API Testing.

What we will need?

  1. A Tool to perform API queries (e.g Postman)
  2. API endpoint to try those requests on

Let’s start

Create a new account and download Postman or use the Web version. Create a new collection for the API Calls and create a new request there. Call it “Get Weather”, for example.

Main window of the Postman app

Insert this request there:

https://www.7timer.info/bin/astro.php?lon=19.818699&lat=41.327545&ac=0&unit=metric&output=json

Press the “Send” button and observe the area at the bottom:

Postman: Response for the request

When you see the request — it means that it was able to successfully communicate with the server and get the response back to you.

You can play around with the parameters and enable/disable some of those. Let’s try disabling the “output” parameter by clicking and disabling it.

You will see that we now see the visual representation instead of the JSON output:

Postman: Visualizing the response

This is how we adjust our request to get the specific data that we need. This is how most of the applications work those days — by sending and receiving requests.

But sometimes you need to provide a specific API key that is necessary to access the data. This is typically done in the “Authorization” tab of the “Postman” app.

Postman: Authorization tab

Writing Tests / Performing assertions

Since we now know how to make those requests — how about writing simple scripts to actually perform testing of those areas of the app.

Go ahead to the “Tests” tab and paste this code there:

pm.test(“Status code is 200”, function () {
pm.response.to.have.status(200);
});
pm.test(“Body matches string”, function () {
pm.expect(pm.response.text()).to.include(“product”);
});

Press “Send” button and observe the output:

Postman: Verifying the Test Assertions Results

Here is what we are going to see. We have two tests. One test is verifying that the response code from the server is 200, and the other one confirms that there is a specific text string “product” in our JSON response.

There are snippets and examples on the right side in the “Tests” tab that you can explore. Imagine how powerful it could be to be able to quickly check the status of your Backend.

Conclusion

You can use powerful tools such as Postman to be able to send API requests and get the response back. You can also run test scripts using Postman and make assertions to confirm that the output is correct.

Being a QA Engineer is no longer about performing manual testing only, but also about being exposed to a wide range of tools. Hopefully, this article provided you some insight into it.

API
Software Engineering
Testing
Computer Science
Engineering
Recommended from ReadMedium