Monitor results analysis in Postman - Build an Automation Script
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.
Now add data-driven testing by running the monitor tests with 3 different API endpoints and verify results for each.
Practice
Solution
Step 1: Understand monitor results role
Monitor results show how API tests perform over time, highlighting issues.Step 2: Identify main goal of analysis
Analyzing results helps track API health and find failures quickly.Final Answer:
To track API health and detect failures over time -> Option CQuick Check:
Monitor results = API health tracking [OK]
- Confusing monitor results with request creation
- Thinking monitor results are for UI design
- Assuming monitor results deploy apps
Solution
Step 1: Identify filter purpose
Filtering by status narrows results to specific outcomes like failures.Step 2: Choose filter to find failures
Filtering by status: Failed shows only failed test runs quickly.Final Answer:
Filter by status: Failed -> Option DQuick Check:
Status filter = find failures fast [OK]
- Sorting by request name does not isolate failures
- Filtering by response time shows speed, not failures
- Sorting by creation date orders runs but doesn't filter failures
{"runId":123, "status":"failed", "tests": {"responseCodeCheck": false, "bodyCheck": true}}Which test failed in this run?
Solution
Step 1: Read test results in JSON
The tests object shows responseCodeCheck: false and bodyCheck: true.Step 2: Interpret boolean test results
false means test failed, true means test passed.Final Answer:
responseCodeCheck -> Option BQuick Check:
False test = failure [OK]
- Assuming true means failure
- Ignoring test result booleans
- Confusing test names
Solution
Step 1: Analyze monitor showing all passes
If monitor shows all passes but API is down, tests likely miss failure detection.Step 2: Identify missing test checks
Not checking response status codes means failures go unnoticed.Final Answer:
Test scripts do not check API response status codes -> Option AQuick Check:
Missing status checks = false passes [OK]
- Assuming monitor is not running without checking
- Thinking API is up despite errors
- Believing monitor results delay causes issue
Solution
Step 1: Understand filtering needs
You want to see only failed tests with slow response times.Step 2: Apply combined filters
Filtering by status: Failed and response time > 2000ms shows exactly those runs.Final Answer:
Filter monitor results by status: Failed and response time > 2000ms -> Option AQuick Check:
Combined filters = precise failure + slow tests [OK]
- Sorting alone does not filter failures
- Filtering by passed misses failures
- Manual checks waste time and risk errors
Ready to prove it?
Pass the test and this pattern moves unknown
