Test Overview
This test sends a DELETE request to remove a user by ID and verifies that the response status code is 200, confirming successful deletion.
This test sends a DELETE request to remove a user by ID and verifies that the response status code is 200, confirming successful deletion.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response body confirms deletion", function () { const jsonData = pm.response.json(); pm.expect(jsonData.message).to.eql("User deleted successfully"); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Postman app is open with DELETE request prepared | — | PASS |
| 2 | Sends DELETE request to https://api.example.com/users/123 | Request sent to server to delete user with ID 123 | — | PASS |
| 3 | Receives response with status code 200 and JSON body | Response body: {"message": "User deleted successfully"} | Check if status code is 200 | PASS |
| 4 | Checks response body message equals 'User deleted successfully' | Response JSON parsed | Verify response message confirms deletion | PASS |
| 5 | Test ends with all assertions passed | Test report shows success | — | PASS |
DELETE request in Postman?pm.sendRequest({
url: 'https://api.example.com/items/45',
method: 'DELETE'
}, function (err, res) {
pm.test('Status code is 200 or 204', function () {
pm.expect(res.code).to.be.oneOf([200, 204]);
});
});DELETE https://api.example.com/items
Body: { "id": 10 }Pass the test and this pattern moves unknown