Benchmark API response time for GET /users endpoint
Preconditions (2)
✅ Expected Result: The GET /users request returns status code 200 and the response time is under 500 milliseconds
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.
Now add data-driven testing with 3 different API endpoints to benchmark their response times
pm.response.responseTime measure in Postman?pm.response.responseTimepm.expect(value).to.be.below(limit) to check if value is less than limit.pm.expect(pm.response.responseTime).to.be.below(500). pm.test('Response time is less than 500ms', () => pm.response.responseTime < 500); lacks assertion method. The version checking greater than 500 reverses the logic, and the version checking equality to 500 uses the wrong matcher.pm.test('Check response time', () => {
pm.expect(pm.response.responseTime).to.be.below(300);
});to.be.below(300).pm.test('Response time under 200ms', () => {
pm.expect(pm.response.responseTime).below(200);
});to.be.below(200). The code uses pm.expect(...).below(200) missing to.be.to.be, the assertion does not execute properly and silently passes, ignoring the actual response time.to.be before below(200) -> Option Cpm.response.responseTime after each request automates response time checks for all requests without repeating code. Writing a test script in each request using pm.expect(pm.response.responseTime).to.be.below(400) duplicates code, manually checking response times in Postman console after running all requests is error-prone, and setting a global variable with response time and comparing after all requests finish complicates logic unnecessarily.Pass the test and this pattern moves unknown