Test Overview
This test runs a Postman collection using Newman with a specified environment file. It verifies that the API request uses environment variables correctly and the response status is 200 OK.
This test runs a Postman collection using Newman with a specified environment file. It verifies that the API request uses environment variables correctly and the response status is 200 OK.
const newman = require('newman'); newman.run({ collection: require('./collection.json'), environment: require('./environment.json'), reporters: 'cli' }, function (err, summary) { if (err) { throw err; } const run = summary.run; const failures = run.failures; if (failures.length > 0) { console.error('Test failed with failures:', failures); process.exit(1); } else { console.log('All tests passed!'); } });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Newman starts running the Postman collection with the specified environment file | Newman CLI initializes and loads collection.json and environment.json | - | PASS |
| 2 | Newman sends API requests using variables from environment.json | API requests are constructed with environment variable values | - | PASS |
| 3 | Newman receives responses and runs tests defined in the collection | Responses received, tests executed for each request | Check that response status code is 200 | PASS |
| 4 | Newman summarizes test results and reports via CLI | Test summary shows zero failures | Verify no test failures in summary.run.failures | PASS |