Verify GET API returns correct user data
Preconditions (2)
✅ Expected Result: The API returns status 200 and the correct user data in JSON format
pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); const responseJson = pm.response.json(); pm.test('User ID is 123', function () { pm.expect(responseJson.id).to.eql(123); }); pm.test('User name is John Doe', function () { pm.expect(responseJson.name).to.eql('John Doe'); }); pm.test('User email is john.doe@example.com', function () { pm.expect(responseJson.email).to.eql('john.doe@example.com'); });
This Postman test script checks the API response after sending a GET request.
First, it verifies the status code is 200, meaning the request succeeded.
Then, it parses the JSON response and checks that the user ID, name, and email match the expected values.
Using pm.test and pm.expect ensures clear, readable assertions that will show pass or fail in the Postman test results.
This approach helps confirm the API returns correct data and is working as expected.
Now add data-driven testing with 3 different user IDs and verify their data
Pass the test and this pattern moves unknown