Test Overview
This test sends a complex API request with multiple parameters and checks the response for correct data and status. It verifies that advanced tests can handle complex scenarios by validating multiple conditions in one test.
This test sends a complex API request with multiple parameters and checks the response for correct data and status. It verifies that advanced tests can handle complex scenarios by validating multiple conditions in one test.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has expected user data", function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('user'); pm.expect(jsonData.user).to.have.property('id').that.is.a('number'); pm.expect(jsonData.user).to.have.property('roles').that.is.an('array').that.includes('admin'); }); 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 | Test starts and sends API request with complex parameters | Postman sends HTTP GET request to API endpoint with query parameters for user details and roles | - | PASS |
| 2 | Receives HTTP response from API | Response received with status code 200 and JSON body containing user data | Check if status code is 200 | PASS |
| 3 | Parses JSON response and verifies user object and roles array | JSON parsed with user object containing id and roles | Verify user object exists, id is number, roles include 'admin' | PASS |
| 4 | Checks response time is under 500 milliseconds | Response time recorded by Postman | Response time < 500ms | PASS |
| 5 | Test ends with all assertions passed | Test report shows all checks passed | - | PASS |