Test Overview
This test runs a Postman collection using Newman with a data file to provide multiple sets of input. It verifies that the API responds correctly for each data row.
This test runs a Postman collection using Newman with a data file to provide multiple sets of input. It verifies that the API responds correctly for each data row.
const newman = require('newman'); newman.run({ collection: require('./example_collection.json'), iterationData: './data.json', reporters: ['cli'] }, function (err, summary) { if (err) { throw err; } const failures = summary.run.failures.length; if (failures > 0) { console.error(`${failures} tests failed.`); process.exit(1); } else { console.log('All tests passed.'); } });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Newman starts running the Postman collection with the data file './data.json'. | Newman CLI initializes and loads the collection and data file. | - | PASS |
| 2 | Newman runs the first iteration using the first row of data from the data file. | API request is sent with first data set; response received. | Check if response status is 200 and response body matches expected values for first data row. | PASS |
| 3 | Newman runs the second iteration using the second row of data from the data file. | API request is sent with second data set; response received. | Check if response status is 200 and response body matches expected values for second data row. | PASS |
| 4 | Newman completes all iterations from the data file and summarizes results. | Summary shows zero failures. | Verify that no test failures occurred during any iteration. | PASS |
| 5 | Test script logs 'All tests passed.' and exits with success code. | Console output confirms success. | - | PASS |