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.
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.
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'); } });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts by invoking Newman to run the Postman collection file 'MyCollection.json'. | Newman CLI initializes and loads the collection with all API requests. | - | PASS |
| 2 | Newman sends the first API request defined in the collection. | Request sent to API endpoint; waiting for response. | - | PASS |
| 3 | Newman receives response and checks if status code is 200. | Response received with HTTP status code 200. | Verify response status code equals 200. | PASS |
| 4 | Newman 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 |
| 5 | Newman completes running the collection and summarizes results. | Summary shows zero failures. | Check that no request failed the status code 200 check. | PASS |
| 6 | Test ends with console output confirming all requests passed. | Console displays 'All requests passed with status 200'. | - | PASS |