0
0
Postmantesting~8 mins

Flow creation in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Flow creation
Folder Structure
postman-project/
├── collections/
│   ├── user-authentication.postman_collection.json
│   ├── product-api.postman_collection.json
│   └── order-api.postman_collection.json
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── production.postman_environment.json
├── tests/
│   ├── pre-request-scripts/
│   │   └── auth-setup.js
│   ├── test-scripts/
│   │   └── validate-response.js
│   └── flow-scripts/
│       └── order-flow.js
├── globals.json
├── README.md
└── postman_collection_runner.json
Test Framework Layers
  • Collections: Group related API requests representing features or modules.
  • Environments: Store variables like base URLs, tokens for different deployment stages.
  • Pre-request Scripts: JavaScript code executed before requests to set up data or tokens.
  • Test Scripts: JavaScript assertions to validate API responses after requests.
  • Flow Scripts: Scripts or chained requests that create a sequence of API calls to simulate real user flows.
  • Globals: Variables accessible across collections and environments for shared data.
Configuration Patterns
  • Environment Files: Use separate JSON files for dev, staging, and production to switch contexts easily.
  • Variables: Define variables for URLs, credentials, tokens to avoid hardcoding.
  • Authorization: Store tokens or credentials in environment variables and refresh them using pre-request scripts.
  • Collection Runner: Use Postman Collection Runner or Newman CLI with environment files to run flows in different setups.
  • Data Files: Use CSV or JSON data files for data-driven testing in flows.
Test Reporting and CI/CD Integration
  • Newman CLI: Run Postman collections from command line with detailed JSON or HTML reports.
  • Reporters: Use built-in reporters like HTML, JSON, JUnit for readable test results.
  • CI/CD Integration: Integrate Newman runs in pipelines (GitHub Actions, Jenkins, GitLab CI) to automate flow tests on code changes.
  • Slack/Email Notifications: Configure pipeline to send test results notifications to teams.
  • Version Control: Store collections and environment files in Git for traceability and collaboration.
Best Practices for Flow Creation in Postman
  1. Modular Collections: Break flows into smaller collections or folders for easier maintenance.
  2. Use Variables: Avoid hardcoding values; use environment and global variables for flexibility.
  3. Clear Naming: Name requests and scripts clearly to describe their role in the flow.
  4. Chaining Requests: Use test scripts to save response data as variables for use in subsequent requests to simulate real user journeys.
  5. Validate Responses: Always add assertions to check status codes, response times, and data correctness.
Self Check

Where in this folder structure would you add a new request to test the payment flow in the order process?

Key Result
Organize Postman flows using collections, environments, scripts, and integrate with CI/CD for automated API testing.