0
0
Postmantesting~10 mins

Path parameters in Postman - Test Execution Trace

Choose your learning style9 modes available
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.

Test Code - Postman
Postman
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));
});
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsPostman app is open with the GET request configured to https://api.example.com/users/:userId with userId=5-PASS
2Send GET request to https://api.example.com/users/5Request sent, waiting for response-PASS
3Receive response with status 200 and JSON body {"id":5, "name":"John Doe"}Response received in PostmanCheck response status is 200PASS
4Run test to verify response status codeTest script executespm.response.to.have.status(200)PASS
5Run test to verify response user ID matches path parameterTest script executespm.expect(jsonData.id).to.eql(5)PASS
Failure Scenario
Failing Condition: Response status is not 200 or returned user ID does not match the path parameter
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify first after sending the GET request?
ARequest URL contains query parameters
BResponse body contains user name
CResponse status code is 200
DResponse time is less than 1 second
Key Result
Always verify that path parameters are correctly inserted in the request URL and that the response matches the expected data for those parameters.