0
0
Postmantesting~10 mins

Workflow sequencing in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test checks a simple API workflow in Postman where a user is created, then retrieved, and finally deleted. It verifies that each step completes successfully and the data matches expectations.

Test Code - Postman
Postman
pm.test("Create User - Status 201", function () {
    pm.response.to.have.status(201);
    const jsonData = pm.response.json();
    pm.environment.set("userId", jsonData.id);
});

pm.test("Get User - Status 200 and correct user", function (done) {
    pm.sendRequest({
        url: `https://api.example.com/users/${pm.environment.get("userId")}`,
        method: 'GET'
    }, function (err, res) {
        pm.expect(res).to.have.property('code', 200);
        const user = res.json();
        pm.expect(user.id).to.eql(pm.environment.get("userId"));
        done();
    });
});

pm.test("Delete User - Status 204", function (done) {
    pm.sendRequest({
        url: `https://api.example.com/users/${pm.environment.get("userId")}`,
        method: 'DELETE'
    }, function (err, res) {
        pm.expect(res).to.have.property('code', 204);
        done();
    });
});
Execution Trace - 4 Steps
StepActionSystem StateAssertionResult
1Send POST request to create a new userAPI server receives user creation requestResponse status is 201 CreatedPASS
2Extract user ID from response and save to environment variableUser ID stored for next requests-PASS
3Send GET request to retrieve the created user using saved user IDAPI server returns user dataResponse status is 200 OK and user ID matches saved IDPASS
4Send DELETE request to remove the created user using saved user IDAPI server deletes userResponse status is 204 No ContentPASS
Failure Scenario
Failing Condition: User ID is missing or incorrect, causing GET or DELETE requests to fail
Execution Trace Quiz - 3 Questions
Test your understanding
What does the first test step verify?
AThe user creation returns status 201 Created
BThe user data matches expected values
CThe user is deleted successfully
DThe GET request returns status 200 OK
Key Result
Always save and reuse dynamic data like IDs between API calls to maintain correct workflow sequencing in tests.