Newman: Execute group of collections in SEQUENTIALLY

Created on 8 Jan 2018  路  1Comment  路  Source: postmanlabs/newman

Hello Newman guys,
I need to execute collections in SEQUENTIALLY because collections interact together.
Below you can see details.

Version and environment information:
-->

  1. Newman Version (can be found via newman -v): 3.8.3
  2. OS details (type, version, and architecture): Windows7 64bit
  3. Are you using Newman as a library, or via the CLI? -> CLI
  4. Did you encounter this recently, or has this bug always been there: -> always
  5. Expected behaviour: --> execute collections in SEQUENTIALLY, similar as newman.run. Please extend the execution for example: newman.run_parallel, newman.run_sequentially
  6. Command / script used to run Newman: --> node run-collections-in-directory.js
  7. Sample collection, and auxiliary files (minus the sensitive details): --> "node run-collections-in-directory.js", where I'm using newman.run(...)

Steps to reproduce the problem:

  1. It's described in the newman examples --> run-collections-in-directory.js
  2. node run-collections-in-directory.js
    -->

Detail you can see in the mails Chris de Sousa (Postman) help@getpostman.com with subject:
"Newman: Execute all collections from directory sequentially"

documentation examples question

Most helpful comment

@xsedlak While the default example you've mentioned runs collections in parallel, it can be tweaked for serial runs as follows:

var fs = require('fs'),
    async = require('async'), // https://npmjs.org/package/async
    newman = require('newman');

fs.readdir('./examples', function (err, files) {
    if (err) { throw err; }

    // we filter all files with JSON file extension
    files = files.filter(function (file) {
        return (file.substr(-5) === '.json');
    });

    // now wer iterate on each file name and call newman.run using each file name
    async.eachSeries(files, function (file, next) {
        newman.run({
            collection: require(`${__dirname}/${file}`)
        }, function (err, summary) {
            // finally, when the collection executes, print the status
            console.info(`${file}: ${err ? err.name : 'ok'}!`);
            next(err, summary);
        });
    }, function (err, results) {
       // process the errors/results here
    });
});

>All comments

@xsedlak While the default example you've mentioned runs collections in parallel, it can be tweaked for serial runs as follows:

var fs = require('fs'),
    async = require('async'), // https://npmjs.org/package/async
    newman = require('newman');

fs.readdir('./examples', function (err, files) {
    if (err) { throw err; }

    // we filter all files with JSON file extension
    files = files.filter(function (file) {
        return (file.substr(-5) === '.json');
    });

    // now wer iterate on each file name and call newman.run using each file name
    async.eachSeries(files, function (file, next) {
        newman.run({
            collection: require(`${__dirname}/${file}`)
        }, function (err, summary) {
            // finally, when the collection executes, print the status
            console.info(`${file}: ${err ? err.name : 'ok'}!`);
            next(err, summary);
        });
    }, function (err, results) {
       // process the errors/results here
    });
});
Was this page helpful?
0 / 5 - 0 ratings