0
0
Postmantesting~15 mins

Why Postman supports non-functional testing - Automation Benefits in Action

Choose your learning style9 modes available
Verify API response time and status code using Postman
Preconditions (2)
Step 1: Open Postman and create a new GET request
Step 2: Enter the API endpoint URL in the request URL field
Step 3: Click the Send button to send the request
Step 4: Observe the response status code and response time displayed in Postman
✅ Expected Result: The response status code should be 200 OK and the response time should be less than 2000 milliseconds
Automation Requirements - Postman Test Scripts (JavaScript)
Assertions Needed:
Verify response status code is 200
Verify response time is less than 2000 ms
Best Practices:
Use pm.response.to.have.status() for status code assertion
Use pm.response.responseTime to check response time
Write clear and simple test scripts inside the Tests tab
Avoid hardcoding values; use environment variables if needed
Automated Solution
Postman
pm.test('Status code is 200', () => {
    pm.response.to.have.status(200);
});

pm.test('Response time is less than 2000ms', () => {
    pm.expect(pm.response.responseTime).to.be.below(2000);
});

The first test checks if the API response status code is exactly 200, which means the request was successful.

The second test checks if the response time is less than 2000 milliseconds, ensuring the API is fast enough.

Both tests use Postman's built-in pm object and assertion methods for clarity and reliability.

Common Mistakes - 3 Pitfalls
Not checking the response time in tests
Hardcoding API URLs and values directly in test scripts
Using incorrect assertion syntax like pm.response.status instead of pm.response.to.have.status()
Bonus Challenge

Now add tests to verify the API response contains a specific JSON field with expected value for 3 different endpoints

Show Hint