Currently I have a number of Postman collections which we wish to use as a set of smoke tests. I anticipated I would be able to point at a directory containing postman collections and for all of these to be executed one by one. However, this is not possible. My expectation was incorrect and I have worked around the issue by having multiple newman run commands, though this seems like waste/duplication.
newman -v): 3.3.1This is not something that is there in the roadmap. As such, use Newman programmatically to achieve this.
https://github.com/postmanlabs/newman/blob/develop/examples/run-collections-in-directory.js
Shamasis - Thanks for the example on reading a folder form disk..
I plan to use it for smoke tests as well.
How might one define the folder for the output directory in node?
I've tried :
export: 'path to place output'
and I can't use dashes in a object key ( cli-export, json-export etc..)
So I am not sure what to use to set the path.
I solved this issue in a bit another way: have written a tool for combining several collections into one.
https://www.npmjs.com/package/postman-combine-collections
We successfully use it in CI run.
I solved this by having a Command Line build step in TeamCity and running:
for collection in ./tests/*; do newman run "$collection" --environment ./envs/dev.postman_environment.json' -r cli,teamcity; done
@Ne4istb - if you combine collection how to specify the data file for each of the collection while combining?
if its single we are specifying lik example below
"newman run collection.json -e QA_environmentvariable.json -g globalvariable.json -d Data.csv"
can you give some example code? like if i have to combine 2 collection with data like below whats the sample code format ?
Collection1.json - data1.json - environ1.json
collection2.json - data2.json - environ2.json
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"
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.
Most helpful comment
I solved this issue in a bit another way: have written a tool for combining several collections into one.
https://www.npmjs.com/package/postman-combine-collections
We successfully use it in CI run.