Test Overview
This test sends a GET request using Postman with a path parameter to retrieve a specific user's details. It verifies that the response status is 200 and the returned user ID matches the path parameter.
This test sends a GET request using Postman with a path parameter to retrieve a specific user's details. It verifies that the response status is 200 and the returned user ID matches the path parameter.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has correct user ID", function () { const userId = pm.variables.get("userId"); const jsonData = pm.response.json(); pm.expect(jsonData.id).to.eql(parseInt(userId)); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Postman app is open with the GET request configured to https://api.example.com/users/:userId with userId=5 | - | PASS |
| 2 | Send GET request to https://api.example.com/users/5 | Request sent, waiting for response | - | PASS |
| 3 | Receive response with status 200 and JSON body {"id":5, "name":"John Doe"} | Response received in Postman | Check response status is 200 | PASS |
| 4 | Run test to verify response status code | Test script executes | pm.response.to.have.status(200) | PASS |
| 5 | Run test to verify response user ID matches path parameter | Test script executes | pm.expect(jsonData.id).to.eql(5) | PASS |