I have a postman collection with 3 requests (A,B,C) and I have 3 different environments: "dev", "test", "uat". I would like to create a Run which will run all 3 requests from the collection against the 3 different envs. So the effective runs will be:
env:dev, request A
env:dev, request B
env:dev, request C
env:test, request A
env:test, request B
env:test, request C
env:uat, request A
env:uat, request B
env:uat, request C
Is there a simple way to achieve it in Postman?
Newman will address your question.
Run newman with environment
newman run your.postman_collection.json -e dev.postman_environment.json
newman run your.postman_collection.json -e test.postman_environment.json
newman run your.postman_collection.json -e uat.postman_environment.json
Demo REST API
https://freetestapi.com/apis/animals
Get Animal by [animal name] query https://freetestapi.com/api/v1/animals?search=[animal name]
example
https://freetestapi.com/api/v1/animals?search=Lion
request A
https://freetestapi.com/api/v1/animals?search={{request_A}}
Tests
tab
var jsonData = JSON.parse(responseBody);
console.log(jsonData[0].name);
pm.expect(jsonData[0].name).to.eql(pm.environment.get("request_A"));
request B
https://freetestapi.com/api/v1/animals?search={{request_B}}
Tests
tab
var jsonData = JSON.parse(responseBody);
console.log(jsonData[0].name);
pm.expect(jsonData[0].name).to.eql(pm.environment.get("request_B"));
request C
https://freetestapi.com/api/v1/animals?search={{request_C}}
Tests
tab
var jsonData = JSON.parse(responseBody);
console.log(jsonData[0].name);
pm.expect(jsonData[0].name).to.eql(pm.environment.get("request_C"));
Export collection
Will be saved as 1-demo.postman_collection.json
Export environment
Will be saved as dev.postman_environment.json
Other two environments
Will be saved as test.postman_environment.json
Will be saved as uat.postman_environment.json
newman
with three environments by bashSave as run.sh
newman run 1-demo.postman_collection.json -e dev.postman_environment.json
newman run 1-demo.postman_collection.json -e test.postman_environment.json
newman run 1-demo.postman_collection.json -e uat.postman_environment.json
./run.sh