0
0
Postmantesting~8 mins

POST request in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - POST request
Folder Structure for Postman API Testing
postman-project/
├── collections/
│   └── user-api.postman_collection.json
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── prod.postman_environment.json
├── tests/
│   └── postman-tests.js
├── scripts/
│   └── pre-request-scripts.js
├── globals.json
└── README.md
    
Test Framework Layers in Postman
  • Collections: Group of API requests including POST requests organized by feature or service.
  • Environments: Variables for different deployment stages (dev, staging, prod) like base URLs and tokens.
  • Pre-request Scripts: JavaScript code run before the POST request to set headers or generate tokens.
  • Tests: JavaScript assertions that run after the POST response to verify status codes and response data.
  • Globals: Variables accessible across collections and environments for shared data.
Configuration Patterns
  • Environment Variables: Store base URLs, API keys, and tokens per environment to switch easily.
  • Collection Variables: Use for data specific to the collection like endpoint paths.
  • Pre-request Scripts: Dynamically generate auth tokens or timestamps before POST requests.
  • Global Variables: Share data like user IDs across multiple collections or requests.
  • Data Files: Use CSV or JSON files for data-driven POST requests in Collection Runner.
Test Reporting and CI/CD Integration
  • Use Newman CLI to run Postman collections in CI pipelines (GitHub Actions, Jenkins).
  • Generate reports in formats like HTML, JSON, or JUnit using Newman reporters.
  • Integrate with CI tools to fail builds on test failures for POST request validations.
  • Use Postman monitors for scheduled runs and email notifications on failures.
Best Practices for POST Request Frameworks in Postman
  • Organize requests in collections by feature or API resource for clarity.
  • Use environment variables to avoid hardcoding URLs and secrets.
  • Write clear, simple test scripts to check status codes and response body fields.
  • Use pre-request scripts to handle authentication and dynamic data generation.
  • Run collections with data files for data-driven testing of POST requests.
Self Check Question

Where in this folder structure would you add a new POST request to create a user?

Key Result
Organize POST request tests in Postman collections with environment variables, pre-request scripts, and Newman for CI integration.