0
0
Postmantesting~8 mins

Example requests and responses in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Example requests and responses
Folder Structure
postman_collection_project/
├── collections/
│   └── api_tests.postman_collection.json
├── environments/
│   ├── dev_environment.postman_environment.json
│   └── prod_environment.postman_environment.json
├── tests/
│   └── example_test_script.js
├── reports/
│   └── test_report.html
├── data/
│   └── test_data.json
└── README.md
    
Test Framework Layers
  • Collections: Store API requests grouped by feature or endpoint.
  • Environments: Define variables like base URLs, tokens for different setups (dev, prod).
  • Tests: Scripts that run assertions on API responses using Postman test scripts or external JS.
  • Data: External JSON files for data-driven testing (e.g., different user inputs).
  • Reports: Generated test run reports showing pass/fail results.
Configuration Patterns

Use Postman environments to manage configuration:

  • Environment Variables: Store base URLs, API keys, tokens to switch easily between dev, test, prod.
  • Global Variables: For values shared across all environments.
  • Pre-request Scripts: Set or update tokens dynamically before requests.
  • Collection Variables: Variables scoped to a collection for modularity.
Test Reporting and CI/CD Integration
  • Use Newman (Postman CLI) to run collections from command line.
  • Generate HTML or JSON reports with Newman reporters.
  • Integrate Newman runs into CI/CD pipelines (Jenkins, GitHub Actions) to automate API tests on code changes.
  • Reports show which requests passed or failed with detailed assertion messages.
Best Practices
  1. Organize requests logically in collections by feature or endpoint.
  2. Use environment variables to avoid hardcoding URLs or secrets.
  3. Write clear, simple test scripts with meaningful assertions.
  4. Keep test data separate from requests for easy updates and reusability.
  5. Automate test runs with Newman and integrate with CI/CD for continuous feedback.
Self Check

Where would you add a new API request for user login in this framework structure?

Key Result
Organize Postman API tests with collections, environments, scripts, and automate runs using Newman for reliable API testing.