Importance of Postman in Writing Test Scripts and Cases

Posted By : Sanjana Singh | 29-Aug-2019

As a QA, writing test cases is very important. When a new code has been introduced, test cases ensure that your API is working as intended. You can write test cases, run APIs, write test scripts in postman for any request. To write test cases, it is important to test the functionality of the API. Firstly, let's take a look at What API is.

 

What is an API?

API stands for Application Programming Interface. An API is a software that acts as an intermediate between client and server or between two applications. It allows two applications to interact with each other. It maintains the process of sending the request to the destination and getting back the response regarding that particular request.

 

There are some tools which help in testing the APIs efficiently. One such tool is "Postman".

Importance of Postman in Testing:

  1. Through Postman, we can test the API by simply hitting the URL and request body.
  2. Postman can be used to create test cases both manual and automated.
  3. History is maintainable through Postman scripting.
  4. Postman also manages the workspace.

 

Some of the HTTP methods used in postman for API Testing are as follows: 

  • GET: GET method has been to used to retrieve any specific resource or data by an identifier.
  • HEAD: HEAD method type is a little bit similar to GET, it just returns the header.
  • PUT: PUT method type has been used to update a specific record which has already been created.
  • POST: POST method type has been used to create a new resource. 
  • DELETE: DELETE method type removes the existing record.
  • PATCH: PATCH method type has been used to make a partial modification to any existing resource.

 

Now let's have a look at What is TEST in Postman: 
With Postman, you can add scripts according to your request. Also, you can write test cases both in a manual and automated format. Code added under the Pre-request Script tab will execute before your request is sent, and code added under the Tests tab will execute after your response is received.


In Postman, the request section contains the Tests tab where you can write test cases. The response viewer contains the Test Results tab where the results of the particular test case are visible. Also, you can add scripts to your request to use dynamic variables, pass data between requests, and write test cases. Code added under the Tests tab will execute after your response according to the request has been received.

 

Test Results:
After you run a request with tests, how do you know that your cases are passing or failing?
Click on the Test results tab in the response viewer. The list of all the tests is available in the Test result section having the boolean functionality which demonstrates that the test is passed or failed. 

 


Response body:

 

Test Results:


The pm.test() function has been used to write specifications of the tests inside Postman. This function allows you to name the test accurately which ensures the script accuracy. 

Related Tags

About Author

Author Image
Sanjana Singh

Sanjana is a QA Engineer with skills in Manual Testing and always eager to learn new technologies.

Request for Proposal

Name is required

Comment is required

Sending message..