Skip to content

Instantly share code, notes, and snippets.

@arifsuhan
Last active April 6, 2024 00:45
Show Gist options
  • Save arifsuhan/acc6892f3fab4f397549ac07f4317714 to your computer and use it in GitHub Desktop.
Save arifsuhan/acc6892f3fab4f397549ac07f4317714 to your computer and use it in GitHub Desktop.
Run Postman Collection with Newman Runner in Docker
collection_Json="Reqres_MW.json"
env_Json="Reqres_Env.json"
report_name="Automate Postman Test Reporting"
# Install Newman-Runner and Run Postman Collection Locally
# install packages
npm install -g newman
npm install -g newman-reporter-htmlextra # need for only Way 3(run and generate html report)
# Way 1: run and generate cli report
newman run $collection_Json -e $env_Json
# Way 2: run and generate xml report
newman run $collection_Json -e $env_Json --reporters="junit,cli" --reporter-junit-export="newman-report.xml"
# Way 3: run and generate html report
newman run $collection_Json -e $env_Json -r htmlextra --reporter-htmlextra-title $report_name
# Run Postman Collection Using Docker Locally
# Pull Newman-Runner Docker Images (Choose any one)
docker pull postman/newman
docker pull postman/newman:ubuntu
docker pull postman/newman:alpine
# Run Postman Collection Locally
docker run -v ~/[Host Dir]:/etc/newman -t postman/newman run $collection_Json -e $env_Json
docker run -v ~/[Host Dir]:/etc/newman --entrypoint /bin/sh -t postman/newman -c "npm install -g newman-reporter-htmlextra;newman run $collection_Json -e $env_Json -r htmlextra --reporter-htmlextra-title 'Generated Postman Report' "
# Reference:
# https://github.com/postmanlabs/newman/tree/develop/docker
# https://hub.docker.com/r/postman/newman/
# https://learning.postman.com/docs/running-collections/using-newman-cli/newman-with-docker/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment