0
0
Postmantesting~10 mins

Running a collection in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test runs a Postman collection to verify that all API requests respond with status code 200, ensuring the APIs are reachable and working as expected.

Test Code - Newman (Postman CLI)
Postman
const newman = require('newman');

newman.run({
    collection: require('./MyCollection.json'),
    reporters: 'cli'
}, function (err, summary) {
    if (err) { throw err; }
    const failures = summary.run.failures;
    if (failures.length > 0) {
        console.error('Test failed: Some requests did not return status 200');
        process.exit(1);
    } else {
        console.log('All requests passed with status 200');
    }
});
Execution Trace - 6 Steps
StepActionSystem StateAssertionResult
1Test starts by invoking Newman to run the Postman collection file 'MyCollection.json'.Newman CLI initializes and loads the collection with all API requests.-PASS
2Newman sends the first API request defined in the collection.Request sent to API endpoint; waiting for response.-PASS
3Newman receives response and checks if status code is 200.Response received with HTTP status code 200.Verify response status code equals 200.PASS
4Newman repeats sending requests and checking status codes for all requests in the collection.All requests executed sequentially with responses received.Verify each response status code equals 200.PASS
5Newman completes running the collection and summarizes results.Summary shows zero failures.Check that no request failed the status code 200 check.PASS
6Test ends with console output confirming all requests passed.Console displays 'All requests passed with status 200'.-PASS
Failure Scenario
Failing Condition: One or more API requests return a status code other than 200.
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify for each API request in the collection?
AThat the response status code is 200
BThat the response body contains JSON
CThat the request URL is correct
DThat the request method is POST
Key Result
Always verify the HTTP status code for each API request when running a collection to ensure the APIs are responding correctly.