Verify GET request to retrieve user data
Preconditions (2)
✅ Expected Result: Response status code is 200 OK and response body contains user data with id 1
pm.test('Status code is 200', () => { pm.response.to.have.status(200); }); pm.test('Response body has user id 1', () => { const jsonData = pm.response.json(); pm.expect(jsonData.id).to.eql(1); });
The first test checks that the response status code is exactly 200, which means the GET request was successful.
The second test parses the JSON response body and verifies that the user id field equals 1, confirming the correct user data is returned.
Using pm.test groups assertions with clear names, making test results easy to understand.
Now add data-driven testing with 3 different user IDs (1, 5, 10) to verify each returns status 200 and correct user id
GET request in Postman?GET https://api.example.com/users?id=5
Pass the test and this pattern moves unknown