0
0
Postmantesting~10 mins

Status code assertion 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, indicating a successful request.

Test Code - Postman
Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsPostman app is open with the test script loaded-PASS
2Sends GET request to https://jsonplaceholder.typicode.com/posts/1Request sent, waiting for response-PASS
3Receives response with status code 200Response received with status 200 OK and JSON body-PASS
4Runs assertion pm.response.to.have.status(200)Response status code is 200Check if response status code equals 200PASS
5Test ends with PASSTest result shows status code assertion passed-PASS
Failure Scenario
Failing Condition: Response status code is not 200 (e.g., 404 or 500)
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify in this Postman script?
AThat the response body contains specific text
BThat the request method is POST
CThat the response status code is 200
DThat the response time is less than 1 second
Key Result
Always assert the expected HTTP status code to confirm the API endpoint responds correctly before checking response content.