0
0
Postmantesting~15 mins

Response time benchmarking in Postman - Build an Automation Script

Choose your learning style9 modes available
Benchmark API response time for GET /users endpoint
Preconditions (2)
Step 1: Open Postman and create a new GET request to https://api.example.com/users
Step 2: Send the request
Step 3: Record the response time shown in Postman
Step 4: Verify the response status code is 200
Step 5: Verify the response time is less than 500 milliseconds
✅ Expected Result: The GET /users request returns status code 200 and the response time is under 500 milliseconds
Automation Requirements - Postman test scripts
Assertions Needed:
Response status code is 200
Response time is less than 500 milliseconds
Best Practices:
Use pm.response.to.have.status for status code assertion
Use pm.response.responseTime for response time measurement
Write clear and concise test scripts inside the Tests tab
Avoid hardcoding URLs; use environment variables if possible
Automated Solution
Postman
pm.test('Status code is 200', function () {
    pm.response.to.have.status(200);
});

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

The first test checks that the API returns a status code of 200, which means the request was successful.

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

Both tests use Postman's built-in pm object for assertions, which is the recommended way to write tests in Postman.

Common Mistakes - 3 Pitfalls
Checking response time using deprecated or incorrect properties
Not asserting the status code before checking response time
Hardcoding the API URL inside the test script
Bonus Challenge

Now add data-driven testing with 3 different API endpoints to benchmark their response times

Show Hint