0
0
Postmantesting~5 mins

Status code assertion in Postman - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a status code assertion in API testing?
It is a check to confirm that the API response returns the expected HTTP status code, like 200 for success or 404 for not found.
Click to reveal answer
beginner
How do you write a status code assertion in Postman test scripts?
Use pm.response.to.have.status(expectedCode), for example: pm.response.to.have.status(200) checks if the response status is 200.
Click to reveal answer
beginner
Why is checking the status code important in API testing?
Because it quickly tells if the request was successful, failed, or if there was an error, helping to catch problems early.
Click to reveal answer
beginner
What does a 404 status code mean in API response?
It means the requested resource was not found on the server.
Click to reveal answer
beginner
Show a simple Postman test script to assert the status code is 201.
pm.test('Status code is 201', function () { pm.response.to.have.status(201); });
Click to reveal answer
Which Postman method checks the response status code?
Apm.response.to.have.status()
Bpm.request.to.have.status()
Cpm.response.statusCode()
Dpm.test.status()
What does a 200 status code usually mean?
ARequest successful
BServer error
CResource not found
DUnauthorized access
If you want to check that the API response status is 404, which assertion is correct?
Apm.response.to.have.status(200)
Bpm.response.to.have.status(201)
Cpm.response.to.have.status(500)
Dpm.response.to.have.status(404)
What happens if the status code assertion fails in Postman?
ATest passes silently
BTest fails and shows an error
CPostman crashes
DStatus code changes automatically
Which status code indicates a successful resource creation?
A200
B400
C201
D404
Explain how to write a status code assertion in Postman and why it is useful.
Think about the Postman test script syntax and the purpose of status codes.
You got /4 concepts.
    List common HTTP status codes you might assert in API testing and what they mean.
    Focus on codes that indicate success, client error, and server error.
    You got /4 concepts.