Postman: How to make multiple requests at the same time

前端 未结 8 884
滥情空心
滥情空心 2020-12-12 10:55

I want to POST data from Postman Google Chrome extension.

I want to make 10 requests with different data and it should be at the same time.

8条回答
  •  被撕碎了的回忆
    2020-12-12 11:10

    I don't know if this question is still relevant, but there is such possibility in Postman now. They added it a few months ago.

    All you need is create simple .js file and run it via node.js. It looks like this:

    var path = require('path'),
      async = require('async'), //https://www.npmjs.com/package/async
      newman = require('newman'),
    
      parametersForTestRun = {
        collection: path.join(__dirname, 'postman_collection.json'), // your collection
        environment: path.join(__dirname, 'postman_environment.json'), //your env
      };
    
    parallelCollectionRun = function(done) {
      newman.run(parametersForTestRun, done);
    };
    
    // Runs the Postman sample collection thrice, in parallel.
    async.parallel([
        parallelCollectionRun,
        parallelCollectionRun,
        parallelCollectionRun
      ],
      function(err, results) {
        err && console.error(err);
    
        results.forEach(function(result) {
          var failures = result.run.failures;
          console.info(failures.length ? JSON.stringify(failures.failures, null, 2) :
            `${result.collection.name} ran successfully.`);
        });
      });
    

    Then just run this .js file ('node fileName.js' in cmd).

    More details here

提交回复
热议问题