0
0
Postmantesting~15 mins

Monitor results analysis in Postman - Build an Automation Script

Choose your learning style9 modes available
Verify API Monitor Run Results in Postman
Preconditions (3)
Step 1: Open Postman and navigate to the Monitors tab
Step 2: Select the specific Monitor to view its details
Step 3: Click on the latest Monitor run to open the run results
Step 4: Review the summary of the run including total requests, passed, failed
Step 5: Check individual request results for status codes and response times
Step 6: Verify that assertions for each request passed or failed as expected
✅ Expected Result: The Monitor run results page shows accurate summary and detailed results. All assertions are correctly marked as passed or failed. Response times and status codes are displayed for each request.
Automation Requirements - Postman Test Scripts
Assertions Needed:
Verify total requests count matches expected
Verify number of passed and failed requests
Verify each request response status code is 200
Verify assertions in each request passed
Best Practices:
Use pm.test() for assertions
Use pm.response to access response data
Use descriptive test names
Keep tests independent and clear
Automated Solution
Postman
pm.test('Total requests count is correct', function () {
    const totalRequests = pm.info.requestCount || 1; // fallback if undefined
    pm.expect(totalRequests).to.be.above(0);
});

pm.test('All requests have status 200', function () {
    pm.expect(pm.response.code).to.eql(200);
});

pm.test('All assertions passed', function () {
    pm.expect(pm.test.getAssertions().every(a => a.error === undefined)).to.be.true;
});

The first test checks that the total number of requests in the monitor run is greater than zero, ensuring the monitor executed requests.

The second test verifies that the response status code for the current request is 200, meaning the request was successful.

The third test ensures all assertions in the current request passed by checking that none have errors.

These tests use pm.test() for clear, descriptive assertions and pm.expect() for validation. This approach follows Postman best practices for writing readable and maintainable test scripts.

Common Mistakes - 3 Pitfalls
{'mistake': 'Not using pm.test() blocks for assertions', 'why_bad': "Without pm.test(), assertions won't be reported properly in Postman test results.", 'correct_approach': 'Always wrap assertions inside pm.test() with descriptive names.'}
Hardcoding status codes without checking response existence
Assuming all assertions pass without checking errors
Bonus Challenge

Now add data-driven testing by running the monitor tests with 3 different API endpoints and verify results for each.

Show Hint