0
0
Postmantesting~8 mins

Response time in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Response time
Folder Structure
postman-project/
├── collections/
│   └── api-tests.postman_collection.json
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── prod.postman_environment.json
├── tests/
│   └── response-time-tests.js
├── reports/
│   └── response-time-report.html
├── scripts/
│   └── test-scripts.js
└── postman.config.json
    
Test Framework Layers
  • Collections: Group of API requests organized by feature or endpoint.
  • Environments: Variables for different setups like dev, staging, prod.
  • Tests: Scripts that check response time and other API behaviors.
  • Scripts: Reusable JavaScript functions for assertions and helpers.
  • Reports: Generated test run reports showing pass/fail and response times.
  • Config: Settings for Postman CLI or Newman runs, including environment selection.
Configuration Patterns
  • Environment Files: Store base URLs, API keys, and thresholds for response time per environment.
  • Global Variables: Define max acceptable response time (e.g., 500 ms) to reuse in tests.
  • Postman Config: Use postman.config.json to set default environment and collection paths for automation.
  • Newman CLI: Pass environment and collection files as parameters for CI/CD integration.
Test Reporting and CI/CD Integration
  • Use Newman to run Postman collections from command line.
  • Generate HTML or JSON reports showing response times and assertion results.
  • Integrate Newman runs into CI/CD pipelines (Jenkins, GitHub Actions) to automate tests on each build.
  • Fail builds if response time exceeds defined threshold.
  • Use reports to track performance trends over time.
Best Practices
  1. Set clear response time thresholds based on realistic user expectations.
  2. Use environment variables to easily adjust thresholds per environment.
  3. Write assertions in test scripts to fail tests if response time is too high.
  4. Keep test scripts simple and reusable by extracting common logic into helper scripts.
  5. Run response time tests regularly in CI/CD to catch performance regressions early.
Self Check

Where would you add a new test script that checks if the API response time is under 300 ms?

Key Result
Organize Postman tests with collections, environments, and scripts to measure and assert API response times effectively.