0
0
Postmantesting~8 mins

Folder hierarchy in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Folder hierarchy
Folder Structure
Postman-Tests/
├── Collections/
│   ├── UserManagement.postman_collection.json
│   ├── ProductAPI.postman_collection.json
│   └── Auth.postman_collection.json
├── Environments/
│   ├── Development.postman_environment.json
│   ├── Staging.postman_environment.json
│   └── Production.postman_environment.json
├── Globals/
│   └── globals.postman_globals.json
├── Scripts/
│   ├── pre-request-scripts.js
│   └── test-scripts.js
├── Data/
│   ├── user-data.json
│   └── product-data.json
├── Reports/
│   └── test-run-report.html
└── README.md
Test Framework Layers
  • Collections: Group of API requests organized by feature or service.
  • Environments: Variables for different deployment stages (dev, staging, prod).
  • Globals: Variables shared across all collections and environments.
  • Scripts: JavaScript files for reusable pre-request and test scripts.
  • Data: External JSON files for data-driven testing inputs.
  • Reports: Generated test run reports for analysis.
Configuration Patterns
  • Environment Files: Use separate environment JSON files to switch API endpoints and credentials easily.
  • Global Variables: Store common values like tokens or IDs accessible across collections.
  • Data Files: Use external JSON files for parameterizing requests to support data-driven tests.
  • Script Reuse: Place common pre-request and test scripts in the Scripts folder and reference them in collections.
Test Reporting and CI/CD Integration
  • Use Newman CLI to run Postman collections in CI/CD pipelines.
  • Generate HTML or JSON reports from Newman runs and save them in the Reports folder.
  • Integrate with Jenkins, GitHub Actions, or GitLab CI to automate test execution on code changes.
  • Use environment variables in CI to select target environment dynamically.
Best Practices
  • Organize collections by feature or API domain for clarity.
  • Keep environment-specific data separate to avoid accidental data leaks.
  • Reuse scripts to reduce duplication and ease maintenance.
  • Use data files for testing multiple scenarios without changing requests manually.
  • Automate test runs with Newman and integrate with CI/CD for continuous feedback.
Self Check

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

Key Result
Organize Postman tests with clear folders for collections, environments, scripts, data, and reports to enable maintainable and scalable API testing.