Postman tests run after a request returns a response, which makes them ideal for quick assertions on the result. In a basic test script, you check whether the API behaved as expected by validating status codes, measuring response time, inspecting body values, and comparing data with variables. These assertions are concise, readable, and easy to reuse across requests.
Basic Postman Assertions
Learn how to write simple Postman test scripts that verify status, speed, body values, and variables.
Start Basic TestsWrite focused tests in Postman
Common assertion types
Status code checks
Confirm the response returned the expected HTTP status, such as 200 or 201. This is usually the first assertion because it quickly tells you whether the request succeeded.
Response time checks
Verify that the API responds within an acceptable limit. A simple threshold helps catch slow endpoints before they affect users or downstream tests.
Body value verification
Check specific fields in the response body to confirm the payload contains the right data. This is useful for validating IDs, messages, flags, and other expected values.
Variable-based tests
Use variables to compare dynamic values across requests without hardcoding data. This keeps basic tests flexible when values change between environments or test runs.
Frequently asked questions
How are Postman tests structured?
Tests are written as short JavaScript assertions in the Tests tab and run after the response is received. Each assertion checks one expected outcome, such as the status code, a body field, or response time.
When should I use variables in assertions?
Use variables when the expected value can change by environment, request, or test run. They help you avoid hardcoding values and make basic tests easier to maintain.
What does a failed assertion mean?
A failed assertion means the response did not match the expected condition. It may indicate an API issue, incorrect test data, or an outdated expected value in the script.