Dan Toomey
Testing with
Postman
Deloitte
@daniel2me
A look at some advanced features
Dan Toomey
Deloitte
Senior Integration
Specialist
@daniel2me
/in/danieltoomey
What is Postman?
• Google Chrome app for
testing APIs
• Available as a standalone
app for Mac, Windows,
Linux
• Free! (with limits)
• www.getpostman.com
Postman features
• Collections
• Account based
• Collaboration
• Variables
• Global
• Environment
• Environments
• Tests
• AuthN / AuthZ
• API Mocking
• Command line execution
Postman features
• Collections
• Account based
• Collaboration
• Variables
• Global
• Environment
• Environments
• Tests
• AuthN / AuthZ
• API Mocking
• Command line execution
Postman features
• Collections
• Account based
• Collaboration
• Variables
• Global
• Environment
• Environments
• Tests
• AuthN / AuthZ
• API Mocking
• Command line execution
Postman features
• Collections
• Account based
• Collaboration
• Variables
• Global
• Environment
• Environments
• Tests
• AuthN / AuthZ
• API Mocking
• Command line execution
Postman tests
• Node.js runtime permits scripted behaviour
• Pre-request
• Post-request
• Written in JavaScript
• Chai (Expect/Should)
Postman tests
• Node.js runtime permits scripted behaviour
• Pre-request
• Post-request
• Written in JavaScript
• Chai (Expect/Should)
• Defined / executed
at multiple levels
Postman tests
• Node.js runtime permits scripted behaviour
• Pre-request
• Post-request
• Written in JavaScript
• Chai (Expect/Should)
• Defined / executed
at multiple levels
• Run in batches
• Export reports
DEMO
Running with Newman
# run the collection:
$ newman run mycollection.json
# runs the collection 10 times:
$ newman run mycollection.json -n 10
# run the collection for a particular environment:
$ newman run
https://www.postman.com/collections/cb208e7e64056f
5294e5 -e dev_environment.json
References
• Writing Postman test scripts:
https://learning.getpostman.com/docs/postman/scripts/test-scripts/
• Postman test examples:
https://learning.getpostman.com/docs/postman/scripts/test-examples/
• Chai assertion library:
https://www.chaijs.com/api/bdd/
• Chai.js cheatsheet:
https://devhints.io/chai
• Postman cheat sheet:
https://www.toolsqa.com/postman/postman-cheat-sheet/
• Command line integration with Newman:
https://learning.getpostman.com/docs/postman/collection-runs/command-line-integration-with-
newman/
• Spoontacular (Free API)
https://spoonacular.com/food-api
Thank you!

GIB2021 - Testing with Postman

  • 1.
  • 2.
  • 3.
    What is Postman? •Google Chrome app for testing APIs • Available as a standalone app for Mac, Windows, Linux • Free! (with limits) • www.getpostman.com
  • 4.
    Postman features • Collections •Account based • Collaboration • Variables • Global • Environment • Environments • Tests • AuthN / AuthZ • API Mocking • Command line execution
  • 5.
    Postman features • Collections •Account based • Collaboration • Variables • Global • Environment • Environments • Tests • AuthN / AuthZ • API Mocking • Command line execution
  • 6.
    Postman features • Collections •Account based • Collaboration • Variables • Global • Environment • Environments • Tests • AuthN / AuthZ • API Mocking • Command line execution
  • 7.
    Postman features • Collections •Account based • Collaboration • Variables • Global • Environment • Environments • Tests • AuthN / AuthZ • API Mocking • Command line execution
  • 8.
    Postman tests • Node.jsruntime permits scripted behaviour • Pre-request • Post-request • Written in JavaScript • Chai (Expect/Should)
  • 9.
    Postman tests • Node.jsruntime permits scripted behaviour • Pre-request • Post-request • Written in JavaScript • Chai (Expect/Should) • Defined / executed at multiple levels
  • 10.
    Postman tests • Node.jsruntime permits scripted behaviour • Pre-request • Post-request • Written in JavaScript • Chai (Expect/Should) • Defined / executed at multiple levels • Run in batches • Export reports
  • 11.
  • 12.
    Running with Newman #run the collection: $ newman run mycollection.json # runs the collection 10 times: $ newman run mycollection.json -n 10 # run the collection for a particular environment: $ newman run https://www.postman.com/collections/cb208e7e64056f 5294e5 -e dev_environment.json
  • 13.
    References • Writing Postmantest scripts: https://learning.getpostman.com/docs/postman/scripts/test-scripts/ • Postman test examples: https://learning.getpostman.com/docs/postman/scripts/test-examples/ • Chai assertion library: https://www.chaijs.com/api/bdd/ • Chai.js cheatsheet: https://devhints.io/chai • Postman cheat sheet: https://www.toolsqa.com/postman/postman-cheat-sheet/ • Command line integration with Newman: https://learning.getpostman.com/docs/postman/collection-runs/command-line-integration-with- newman/ • Spoontacular (Free API) https://spoonacular.com/food-api
  • 14.