Is there any command to execute multiple collections through single cmd.
If you have please share it with me. Iām working on a large size project, so for me, itās not possible to maintain all APIs in a single collection.
Can you explain why you need to run them in a single command? Why can you not run multiple commands?
@allenheltondev Yes i can, but i divided my whole project into module and sub-module, i consider Module as a Collection and Sub-Module as a folder under the collection.
So in my project i required approx 15 to 20 collection.
So if need to run complete project i need to hit 15-20 times. i think itās not good for usability .
one more thing is my collection is also depends on each other so i want to execute my complete project through single command, if you have any idea please share with me.
If iām running its individually newman generate a individual report for each collection.
and i want single report for my project.
So please help me if you have any idea about it.
If you want the single report from newman, I canāt think of a way to accomplish what you are trying to solve. If you are fine with multiple reports, just executing newman for each collection would have been the route to go.
If you have postman pro or higher, you could write a script that uses the API to give you all the collections in a workspace. You could then iterate over each collection from the response and run newman for each one. That way your test runner would always be up to date when you add or remove collections.
@ramvishwakarma We run multiple collections daily through newman. We wrote a testrunner in node.js that calls newman as a function. We also defined environment files which have a list of all the collections we want to run in it so when we declare ātestrunner.jsā it runs all the collections we have defined in our environment file.
Example of how we are calling newman:
function testRunner(collection, callback) { const reportOutput = path.join(reportsDirectory, collection.name + '.xml'); //call newman.run to pass `options` object and wait for callback getIterationData(collection); newman.run({ collection: require(collection.filePath), environment: configData, reporters: ['cli', 'junit'], reporter: { junit: { export: reportOutput } } }, function (err, summary) { if (err) { throw err; } console.log('collection run complete!'); callback(summary); });
};
Thank you for your email.
Now itās working for me and for your information, Iāve recently started it. your code helps me a lot but still, Iām facing one problem is that, its save the output report in .xml format I want it in html format like below cmd output:
newman run ForesightCollections.postman_collection4Feb.json -k -e KIBA.postman_environment4Feb.json -r htmlextra --reporter-htmlextra-title āRakuten APIs Reportā
I resolved this problem at my own level.
Hello,
The below value is not set in the header when Iām running a JSON file through node js.
User-Agent
PostmanRuntime/7.21.0
Accept
/
Cache-Control
no-cache
Postman-Token
8048118f-22fe-4ee9-bfa9-e9e2e0452328
Host
stg-fos.rmb-ss.jp
Accept-Encoding
gzip, deflate
Content-Length
129
Connection
keep-alive
please help me to solve this issue.
when Iām running the same JSON file through bellow cmd, itās working fine.
newman run AForesightCommonModules.postman_collection.json -k -e KIBA.postman_environment.json -r htmlextra --reporter-htmlextra-title āRakuten APIs Reportā
Could you please help.
Hmm. Iām not sure. Are you passing the header in a variable/data file? It doesnāt look like it as part of your cmd line.
above value postman automatically add when iām running through above mentioned cmd. but the same JSOP file when iām running through NODE JS runner. It got failed.
Hello,
Is there any way to provide a fail or pass condition under the IF-ELSE, based on condition.
Please see the below code: In that code i want to fail my test case in case if a got any NULL value in " if (obj.emsName === null) ":-
for (var i = 0; i < jsonData.length; i++) {
var obj = jsonData[i];
if (obj.emsName === null) {
console.log("EMS value is null--->"+obj.emsName);
}else{
console.log("EMS value is not null--->"+obj.emsName);
}
}
Please help me
Hi,
You can write the code like below =>
for (var i = 0; i < jsonData.length; i++) {
var obj = jsonData[i];
if (obj.emsName === null) {
console.log("EMS value is null--->"+obj.emsName);
pm.expect(true).to.eql(false);// it will fail your test case
}else{
console.log("EMS value is not null--->"+obj.emsName);
}
}
@spencer.arend please can you tell me how your environment file is set up? Iām not sure how it would pick up collections from environment file and then iterate through it? Need help pls. I have number of collections in a folder and would like to run them one by one. A little bit of info on how you set up test runner would be helpful. Thanks
Sure. I will try my best to outline what we have done.
In the folder where your postman collection lives, we created another folder called āenvsā though you could call this folder whatever you want. In this āenvsā folder we create a .json file with the following information:
{
ānameā: āName of this file will show up when it is imported to postmanā,
āvaluesā: [
{
ākeyā: āsomeKeyā,
āvalueā: āsomeValueā,
āenabledā: true
},
{
ākeyā: āanotherKeyā,
āvalueā: āanotherValueā,
āenabledā: true
}
],
ācollectionsā: [
{
ānameā: ātest_collection_nameā,
āfilePathā: ā./test_collection_filepath.jsonā,
āoptionsā: {}
},
{
ānameā: āsome_other_test_collection_with_iteration_dataā,
āfilePathā: ā./test_collection_filepath.jsonā,
āoptionsā: {
āiterationDataā: ā./iterationDataFilePath.jsonā
}
}
],
ā_postman_variable_scopeā: āenvironmentā,
ā_postman_exported_atā: ā2019-05-30T13:59:48.247Zā,
ā_postman_exported_usingā: āPostman/7.1.1ā
}
In a seperate testRunner.js file (that was constructed using node.js). We set up a function to get the file you just set up above:
function getConfig() {
let envConfig = path.join(envsDirectory, params.environment + ā.jsonā);
configData = require(envConfig);
}
Then, later on in the same node.js file we call newman.run like:
newman.run({
collection: require('./sample-collection.json'),
environment: This is where you would specify configData that we set up earlier
iterationData: if any collections need a seperate iterationData file you can specify that here
folder: If there are any specific folders inside your collection you want to run,
globals: if there are any external global vars that your collection needs,
reporters: ['cli', 'junit'],
reporter: { junit: { export: reportOutput } }
}, function (err, summary) {
if (err) {
throw err;
}
console.log('collection run complete!');
callback(summary);
});
@spencer.arend Thank youā¦ I will give a try
Hello,
Can you please share sample snippet code to call the testRunner javascript function and how to set all the collections list with data file for the specific collection to run the testRunner.
Thanks in advance.
SET postman_collection=Newman.postman_collection.json
SET postman_environment=JGestab.postman_environment.json
SET postman_folder="NewManExecution"
SET postman_data="A252ST_InputSheet_Pari_V0.1.csv"
Html report is not getting generated using newman html extra. I have created a Batch, i want the run to be captured in html file. It executes but the html report is not generated. Can you help me. Please let me know where i made mistake i am unable to figure out. This code works individually. Through batch run it is not.
SET postman_collection=Newman.postman_collection.json
SET postman_environment=JGestab.postman_environment.json
SET postman_folder="NewManExecution"
SET postman_data="A252ST_InputSheet_Pari_V0.1.csv"
SET postman_data1="A515ST_InputSheet_Pari_V0.1.csv"
call newman run %postman_collection% -r htmlextra,cli -e %postman_environment% --folder %postman_folder% -d %postman_data% --insecure
call newman run %postman_collection% -r htmlextra,cli -e %postman_environment% --folder %postman_folder% -d %postman_data1% --insecure
Html report is not getting generated using newman html extra. I have created a Batch, i want the run to be captured in html file. It executes but the html report is not generated. Can you help me. Please let me know where i made mistake i am unable to figure out. This code works individually. Through batch run it is not.
SET postman_collection=Newman.postman_collection.json
SET postman_environment=JGestab.postman_environment.json
SET postman_folder=āNewManExecutionā
SET postman_data=āA252ST_InputSheet_Pari_V0.1.csvā
SET postman_data1=āA515ST_InputSheet_Pari_V0.1.csvā
call newman run %postman_collection% -r htmlextra,cli -e %postman_environment% --folder %postman_folder% -d %postman_data% --insecure
call newman run %postman_collection% -r htmlextra,cli -e %postman_environment% --folder %postman_folder% -d %postman_data1% --insecure