Skip to content

ianoroceo/Postman-Newman

Repository files navigation

Postman - Newman Boilerplate

API Testing with Postman and Newman.

Note: You might find some items that are not optimized. Feel free to create a PR if you want to make some optimization.


Features


Important Notes before Running Test

  • Running API Test using node js. You can use your own Imported Collection and Environment. These are controlled inside the ./conf/conf.js file.

  • Put your postman Collection in ./conf/collection/ and make sure the file name format is <whatever file name you have>_collection.json

  • Put your Environment in ./conf/environment/ and make sure the file name format is <environment>.<whatever name>_environment.json

For more info, please visit Newman API Reference

newman.run({
  collection: require(String(config.Collection)),
  environment: require(String(config.Environment)),
  timeoutRequest: 60000,
  timeoutScript: 60000,
  delayRequest: 500,
  reporters: ['cli', 'htmlextra', 'junit'],
  reporter: {
    htmlextra: {
      export: './report/' + config.ReportName + '_' + config.Label + '.html',
      title: config.ReportName + ' ' + config.Label,
      darkTheme: true,
      skipSensitiveData: false,
    },
    junit: {
      export: './report/' + config.ReportName + '_' + config.Label + '.xml',
    },
  },
}).on('start', function(err, args) {
  console.log('running a collection...');
}).on('done', function(err, summary) {
  if (err || summary.error) {
    console.error('collection run encountered an error.');
  } else {
    console.log('collection run completed.');
  }
});

Running Using Postman

  1. Clone the repo — https://github.com/ianoroceo/Postman-Newman.git

  2. Install Postman - https://www.postman.com/downloads/

  3. Import Collection and Environment

  4. Running Tests using Postman Collection Runs


Running Using Node

  1. (Optional)Install nvm in your machine

  2. Install nodeJs using nvm. You can also install nodeJS without using nvm. Here are some references if you are installing not using nvm

  3. Install your favorite IDE. I used VS Code for this

  4. On your terminal (mac) / cmd (windows), go to your project directory and install the Node Packages using npm install

  5. Run your test. npm run test:dev. To run on other environments, please provide the environment argument

    • Note: before running your test, if you made changes please execute ESLint first
    npm run lint-fix
  6. Once all tests are executed, an aggregated report will be generated under ./report.

  7. Test Results can be also posted on Slack. Please read documentation how to setup Slack Notification

Report Examples

Dashboard Report

Test Run Report


References

About

API Tests using Postman and Newman

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published