0
0
Postmantesting~8 mins

Creating collections in Postman - Framework Setup Guide

Choose your learning style9 modes available
Framework Mode - Creating collections
Folder Structure for Postman Collections
postman-project/
├── collections/
│   ├── UserManagement.postman_collection.json
│   ├── ProductAPI.postman_collection.json
│   └── AuthAPI.postman_collection.json
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── prod.postman_environment.json
├── scripts/
│   ├── pre-request-scripts.js
│   └── test-scripts.js
├── README.md
└── postman.config.json
  
Test Framework Layers in Postman Collections
  • Collections Layer: Group of API requests organized by feature or service (e.g., User Management).
  • Environment Layer: Variables for different environments like dev, staging, and production.
  • Scripts Layer: JavaScript code for pre-request setup and test assertions inside requests.
  • Utilities Layer: Shared helper scripts or functions to reuse across collections.
  • Configuration Layer: Settings for collection runs, environment selection, and global variables.
Configuration Patterns for Postman Collections
  • Environment Files: Use separate JSON files for each environment to store URLs, tokens, and credentials.
  • Global Variables: Store values that are common across all environments, like API keys.
  • Collection Variables: Variables scoped to a specific collection for modularity.
  • Postman Config File: Use postman.config.json to define default environment and collection run settings.
  • Secrets Management: Avoid hardcoding sensitive data; use environment variables or Postman's secret vault.
Test Reporting and CI/CD Integration
  • Newman CLI: Run Postman collections from command line and generate reports in formats like HTML, JSON, or JUnit.
  • CI/CD Integration: Integrate Newman runs into pipelines (Jenkins, GitHub Actions, GitLab CI) for automated testing.
  • Report Visualization: Use tools like newman-reporter-html to create readable test reports.
  • Fail Fast: Configure Newman to stop on first failure to save time.
  • Notifications: Send test results to Slack, email, or dashboards after CI runs.
Best Practices for Creating Postman Collections
  • Organize Requests Logically: Group related API calls in folders within collections for clarity.
  • Use Environment Variables: Avoid hardcoding URLs and credentials; use variables for flexibility.
  • Write Clear Test Scripts: Keep assertions simple and descriptive to understand failures easily.
  • Reuse Scripts: Use pre-request and test scripts to avoid duplication and maintain consistency.
  • Version Control Collections: Export collections and environments to JSON files and store in Git for collaboration.
Self Check Question

Where in this folder structure would you add a new collection for testing the Payment API?

Key Result
Organize API requests into collections with environment variables and scripts for reusable, maintainable automated API testing.