0
0
Postmantesting~8 mins

Pretty, raw, and preview views in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Pretty, raw, and preview views
Folder Structure for Postman Test Collections
postman-project/
├── collections/
│   ├── user-api.postman_collection.json
│   ├── product-api.postman_collection.json
│   └── auth-api.postman_collection.json
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── prod.postman_environment.json
├── tests/
│   ├── user-tests.js
│   ├── product-tests.js
│   └── auth-tests.js
├── reports/
│   └── test-report.html
├── postman.config.json
└── README.md
    
Test Framework Layers in Postman
  • Collections Layer: Group of API requests organized by feature or service.
  • Environment Layer: Variables for different environments like dev, staging, prod.
  • Tests Layer: Scripts written in JavaScript inside Postman to validate responses.
  • Pre-request Scripts Layer: Scripts that run before requests to set up data or headers.
  • Utilities Layer: External scripts or Newman CLI commands to run collections and generate reports.
  • Configuration Layer: Settings for environments, globals, and collection variables.
Configuration Patterns in Postman
  • Environment Files: Use separate JSON files for each environment to store URLs, tokens, and credentials.
  • Collection Variables: Define variables inside collections for reusable values.
  • Global Variables: Use sparingly for values shared across collections.
  • Postman Config File: Store metadata and settings like default environment and collection paths.
  • Newman CLI: Use command line options to specify environment and data files for running tests automatically.
Test Reporting and CI/CD Integration
  • Newman Reports: Generate HTML, JSON, or JUnit reports from Newman test runs.
  • CI/CD Integration: Run Newman commands in pipelines (GitHub Actions, Jenkins, GitLab CI) to automate API testing.
  • Slack or Email Notifications: Configure pipeline steps to send test results to teams.
  • Postman Monitor: Schedule automated runs and get reports inside Postman cloud.
Best Practices for Postman Views and Framework
  • Use Pretty View for Readability: When inspecting API responses, use Pretty view to see formatted JSON or XML for easy understanding.
  • Use Raw View for Debugging: Raw view shows the exact response bytes, useful for checking headers or binary data.
  • Use Preview View for HTML Responses: Preview renders HTML responses as a webpage, helpful for testing web content APIs.
  • Organize Collections Clearly: Group requests logically and name them descriptively for easy navigation.
  • Keep Environment Variables Updated: Regularly update tokens and URLs to avoid test failures.
Self Check Question

Where in this folder structure would you add a new environment file for testing a new API stage?

Key Result
Postman test frameworks organize API requests into collections, use environment files for configuration, and leverage Pretty, Raw, and Preview views to inspect responses effectively.