Hi
Is there a way we can specify different data files /environment files for collections when running them in parallel using the below example.
I have two collections but both use a different data file .
Is it possible to specify data file for each collection when tryin to run it in parallel
https://github.com/postmanlabs/newman/blob/develop/examples/run-collections-in-directory.js
https://github.com/postmanlabs/newman/commit/149dd68bf381bc1938371bdb4aaec316622dff59?_pjax=%23js-repo-pjax-container
@dlpooja89 This can be done by expanding on the example in the link above, as follows:
/**
* @fileOverview A sample script to demonstrate parallel collection runs using async.
*/
var path = require('path'), // ensures that the path is consistent, regardless of where the script is run from
async = require('async'), // https://npmjs.org/pacakge/async
newman = require('../'); // change to require('newman'), if using outside this repository
// Runs the Postman sample collection thrice, in parallel.
async.parallel([
function (cb) {
newman.run(options1, cb);
},
function (cb) {
newman.run(options2, cb);
},
function (cb) {
newman.run(options3, cb
}
],
/**
* The
*
* @param {?Error} err - An Error instance / null that determines whether or not the parallel collection run
* succeeded.
* @param {Array} result - An array of collection run summary objects.
*/
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.`);
});
});
In the snippet above, options1, options2 and options3 are the respective options for the three parallel runs. You can specify the iterationData key (path to CSV/JSON file) in each of these objects.
Thanks kunal.. what if I have two different collections each with a different data and environment file.. is it possible to run this scenario as well in parallel ?
@dlpooja89 Yes, you'll have to ensure that the respective options objects to newman.run are adjusted for environments accordingly. 馃槃
@dlpooja89 @kunagpal - Is there a way we can use two different data files for a single collection? I have a single collection with multiple folders, each needing a different test data. Please advise how this can be done
@azharmohammedk The easiest way to do this is to run your collection on a folder by folder basis, with each folder run being passed the corresponding data file. For instance,
newman run collection.json --folder my_fol1 -d data1.csv
newman run collection.json --folder my_fol2 -d data2.csv
A simple equivalent can also be written for using Newman as a library.
Thanks @kunagpal . Is there a way to have both these runs exported in the same HTML report?
@azharmohammedk Apologies for the delay. Merging run information from multiple collections into one HTML report is not supported at the moment, you'll have to create your own HTML report for such a case.
Hi! @kunagpal is there a way to use 2 different data files for a single folder? Thanks!
Hi! @kunagpal is there a way to use 2 different data files for a single folder? Thanks!
So for our solution we ended up using the Newman Ubuntu docker image which we created with
docker run -v %cd%/../:/etc/newman --name postman_test --entrypoint /bin/bash -t postman/newman_ubuntu1404 "./Scripts/ci-dev-test.sh"
The --entrypoint /bin/bash enables me to run my own custom bash script so that I can run multiple newman instances instead of just one.
then ran the tests using this bash script.
rm -r "./Results"; mkdir -p "./Results"
newman run './Collection.postman_collection.json' -e ./Environment/Dev.postman_environment.json --folder "Folder 1" -d "TestData/Data1.json" -r cli,junit --reporter-cli-no-assertions --reporter-junit-no-assertions --reporter-junit-export "Results/report1.xml"
newman run './Collection.postman_collection.json' -e ./Environment/Dev.postman_environment.json --folder "Folder 1" -d "TestData/Data2.json" -r cli,junit --reporter-cli-no-assertions --reporter-junit-no-assertions --reporter-junit-export "Results/report2.xml"
newman run './Collection.postman_collection.json' -e ./Environment/Dev.postman_environment.json --folder "Folder 2" -d "TestData/Data3.json" -r cli,junit --reporter-cli-no-assertions --reporter-junit-no-assertions --reporter-junit-export "Results/report3.xml"
`
I will be updating this to auto scrape the files and run the testing that way... but for now manual beats nothing. Hopefully this helps someone.
Simple question. How could I set a specific collection with multi CSV files? I need to get all CSV files name from a folder then iterate them.
Most helpful comment
@dlpooja89 This can be done by expanding on the example in the link above, as follows:
In the snippet above,
options1,options2andoptions3are the respective options for the three parallel runs. You can specify theiterationDatakey (path to CSV/JSON file) in each of these objects.