0
0
Postmantesting~8 mins

Send request block in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Send request block
Folder Structure
PostmanCollectionProject/
├── collections/
│   └── MyAPI.postman_collection.json
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── prod.postman_environment.json
├── tests/
│   └── sendRequestTests.postman_test_script.js
├── scripts/
│   └── preRequestScripts.js
├── globals.json
└── README.md
Test Framework Layers
  • Collections: Group of API requests organized by feature or service.
  • Environments: Variables for different deployment stages (dev, staging, prod).
  • Pre-request Scripts: JavaScript code executed before sending a request (e.g., setting tokens).
  • Tests: JavaScript assertions run after receiving a response to validate results.
  • Globals: Variables accessible across collections and environments.
Configuration Patterns
  • Environment Variables: Store base URLs, API keys, and credentials per environment to switch easily.
  • Global Variables: Use for values shared across collections like common headers.
  • Pre-request Scripts: Dynamically set or update variables before requests (e.g., generate auth tokens).
  • Collection Variables: Variables scoped to a collection for modularity.
  • Use Postman Environments: Select environment before running tests to target correct API endpoints.
Test Reporting and CI/CD Integration
  • Postman Test Results: View pass/fail status and detailed logs in Postman Test Runner.
  • Newman CLI: Run collections from command line and generate JSON, HTML, or JUnit reports.
  • CI/CD Integration: Use Newman in pipelines (GitHub Actions, Jenkins, GitLab CI) to automate API tests on code changes.
  • Report Storage: Save reports as artifacts or send notifications on failures.
Best Practices
  • Use Environment Variables: Avoid hardcoding URLs or secrets; switch environments easily.
  • Write Clear Tests: Use simple assertions with descriptive messages for easy debugging.
  • Modularize Requests: Group related requests in collections and use folders for organization.
  • Use Pre-request Scripts: Automate token generation or setup to keep tests independent.
  • Version Control Collections: Export and store collections in Git for collaboration and history.
Self Check

Where in this folder structure would you add a new API request to test user login functionality?

Key Result
Organize Postman API tests using collections, environments, pre-request scripts, and Newman for automation.