Test Overview
This test sends a request to an API endpoint and checks if the response time is within an acceptable limit (less than 500 milliseconds). It verifies the API performance meets the expected speed.
This test sends a request to an API endpoint and checks if the response time is within an acceptable limit (less than 500 milliseconds). It verifies the API performance meets the expected speed.
pm.test("Response time is less than 500ms", function () { pm.expect(pm.response.responseTime).to.be.below(500); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send HTTP GET request to the API endpoint | Postman sends the request and waits for the response | — | PASS |
| 2 | Receive response from the API | Response received with status 200 and response time recorded | — | PASS |
| 3 | Check if response time is less than 500 milliseconds | Response time is measured (e.g., 320ms) | pm.expect(pm.response.responseTime).to.be.below(500); | PASS |
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