0
0
Postmantesting~8 mins

Importing and exporting collections in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Importing and exporting collections
Folder Structure of a Postman Test Project
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
├── scripts/
│   ├── pre-request-scripts.js
│   └── test-scripts.js
├── exports/
│   └── exported-collections/
│       ├── user-authentication-export.json
│       └── product-api-export.json
└── README.md
  
Test Framework Layers in Postman Collections
  • Collections Layer: Contains grouped API requests organized by feature or service.
  • Environment Layer: Holds variables like URLs, tokens, and credentials for different environments.
  • Scripts Layer: Includes pre-request scripts and test scripts to run before or after requests.
  • Exports Layer: Stores exported collection files for sharing or backup.
  • Configuration Layer: Manages environment files and global variables.
Configuration Patterns for Importing and Exporting Collections
  • Importing Collections: Use Postman UI or CLI to import JSON files from the collections/ or exports/exported-collections/ folder.
  • Exporting Collections: Export collections from Postman UI to JSON files saved in exports/exported-collections/ for version control or sharing.
  • Environment Management: Keep environment JSON files in environments/ and import/export as needed to switch contexts.
  • Version Control: Store exported collections and environments in Git or other VCS for team collaboration.
Test Reporting and CI/CD Integration
  • Use Newman (Postman CLI) to run collections in CI/CD pipelines.
  • Generate reports in formats like HTML or JSON using Newman reporters.
  • Integrate test runs with CI tools (Jenkins, GitHub Actions) to automate API testing on code changes.
  • Store exported collections in the repository to ensure consistent test runs across environments.
Best Practices for Importing and Exporting Collections
  • Keep collections small and focused on specific API features for easier maintenance.
  • Use meaningful names for exported collection files including version or date.
  • Regularly export collections after updates to keep backups and share with the team.
  • Use environment variables to avoid hardcoding sensitive data in collections.
  • Document collection purpose and usage in README or Postman description fields.
Self-Check Question

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

Key Result
Organize Postman collections and environments in dedicated folders, export/import JSON files for sharing and automation.