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?
✗ Incorrect
pm.response.to.have.status() is the correct method to assert the response status code.
What does a 200 status code usually mean?
✗ Incorrect
200 means the request was successful and the server returned the expected response.
If you want to check that the API response status is 404, which assertion is correct?
✗ Incorrect
404 means resource not found, so pm.response.to.have.status(404) is correct.
What happens if the status code assertion fails in Postman?
✗ Incorrect
If the assertion fails, Postman marks the test as failed and shows an error message.
Which status code indicates a successful resource creation?
✗ Incorrect
201 means the resource was successfully created on the server.
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.