0
0
Postmantesting~10 mins

Output block in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test sends a GET request to a sample API endpoint and verifies that the response status code is 200 and the response body contains a specific key with the expected value.

Test Code - Postman
Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

pm.test("Response has userId 1", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.userId).to.eql(1);
});
Execution Trace - 3 Steps
StepActionSystem StateAssertionResult
1Send GET request to https://jsonplaceholder.typicode.com/posts/1Request sent, waiting for response-PASS
2Receive response with status code 200 and JSON bodyResponse received: {"userId":1,"id":1,"title":"...","body":"..."}Check if status code is 200PASS
3Parse JSON response bodyParsed JSON object availableVerify jsonData.userId equals 1PASS
Failure Scenario
Failing Condition: Response status code is not 200 or userId is not 1
Execution Trace Quiz - 3 Questions
Test your understanding
What does the first test assertion verify?
AThat the response status code is 200
BThat the response body contains userId 1
CThat the request URL is correct
DThat the response time is less than 1 second
Key Result
Always verify both the response status code and the key data in the response body to ensure the API behaves as expected.