TechPro
Office address BhauAutomation VTP Cygnus Pune bhauautomationlab@gmail.com

Welcome to BhauAutomation!

What is Postman?

Postman is a tool used to send API requests and test API responses. It helps testers check whether an API is working correctly without writing a lot of code.

We can also automate API tests, create collections, manage environments, generate reports, and run tests automatically.

Why Use Postman?

  • Send GET, POST, PUT, and DELETE requests.
  • Check API response status codes.
  • Write automated tests using JavaScript.
  • Organise requests into collections.
  • Run multiple API tests together.
  • Generate test reports using Newman.

Simple Postman Example

Imagine we want to check whether a user API is working correctly.

Step 1: Create a GET Request

Enter this API URL in Postman:

https://jsonplaceholder.typicode.com/users/1

Select the GET method and click Send.

Step 2: Add an API Test

Open the Scripts → Post-response section and add this JavaScript code:

pm.test("API Status Code is 200", function () {
    pm.response.to.have.status(200);
});

pm.test("User name is available", function () {
    const response = pm.response.json();
    pm.expect(response.name).to.exist;
});

Step 3: Run the Request

Click Send and check the Test Results section.

Expected Result:

PASS API Status Code is 200
PASS User name is available

Simple Explanation

  • pm.test() creates an API test case.
  • pm.response accesses the API response.
  • status(200) checks whether the API request was successful.
  • pm.response.json() reads the response data.
  • pm.expect() verifies the expected result.

What is Newman?

Newman is a command-line tool used to run Postman collections automatically. It can also generate test reports and help run API tests as part of a CI/CD process.

Conclusion

Postman makes API testing simple and effective. Beginners can start with GET requests and response validation, then learn collections, environments, Newman, and automated test execution.

Keep Learning with BhauAutomation!

Share:

Leave a Reply

Your email address will not be published. Required fields are marked *