0
0
Postmantesting~10 mins

Why advanced tests handle complex scenarios in Postman - Test Execution Impact

Choose your learning style9 modes available
Test Overview

This test sends a complex API request with multiple parameters and checks the response for correct data and status. It verifies that advanced tests can handle complex scenarios by validating multiple conditions in one test.

Test Code - Postman
Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

pm.test("Response has expected user data", function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property('user');
    pm.expect(jsonData.user).to.have.property('id').that.is.a('number');
    pm.expect(jsonData.user).to.have.property('roles').that.is.an('array').that.includes('admin');
});

pm.test("Response time is less than 500ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(500);
});
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts and sends API request with complex parametersPostman sends HTTP GET request to API endpoint with query parameters for user details and roles-PASS
2Receives HTTP response from APIResponse received with status code 200 and JSON body containing user dataCheck if status code is 200PASS
3Parses JSON response and verifies user object and roles arrayJSON parsed with user object containing id and rolesVerify user object exists, id is number, roles include 'admin'PASS
4Checks response time is under 500 millisecondsResponse time recorded by PostmanResponse time < 500msPASS
5Test ends with all assertions passedTest report shows all checks passed-PASS
Failure Scenario
Failing Condition: API returns status code other than 200 or missing expected user data or roles
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify first after sending the API request?
AThat the status code is 200
BThat the response time is less than 500ms
CThat the user roles include 'admin'
DThat the JSON response is empty
Key Result
Advanced tests handle complex scenarios by validating multiple related conditions in one test, ensuring the system works correctly under realistic and detailed situations.