Bird
Raised Fist0
Postmantesting~8 mins

Running a collection in Postman - Framework Patterns

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Framework Mode - Running a collection
Folder Structure
postman-project/
├── collections/
│   └── my-collection.json
├── environments/
│   ├── dev.postman_environment.json
│   └── prod.postman_environment.json
├── tests/
│   └── test-scripts/
│       └── pre-request-scripts.js
├── reports/
│   └── run-report.html
├── newman-config.json
└── README.md
Test Framework Layers
  • Collections: JSON files defining API requests and test scripts grouped logically.
  • Environments: JSON files holding variables for different deployment stages (dev, prod).
  • Test Scripts: JavaScript code for pre-request and test assertions embedded in collections or external files.
  • Utilities: Helper scripts or libraries for common functions used in tests.
  • Configuration: Newman config files or CLI parameters controlling run options like iteration count, environment, reporters.
  • Reports: Output files generated after running collections, showing pass/fail results and details.
Configuration Patterns
  • Environment Variables: Use separate environment JSON files for dev, test, and prod to switch base URLs and credentials easily.
  • Global Variables: Store values shared across collections, like tokens or user IDs.
  • Newman CLI Options: Pass environment, iteration count, reporters, and export report paths via command line or config JSON.
  • Secrets Management: Avoid hardcoding sensitive data; use environment variables or secure vaults integrated with CI/CD.
  • Collection Versioning: Keep collections under version control to track changes and rollback if needed.
Test Reporting and CI/CD Integration
  • Newman Reports: Generate HTML, JSON, or JUnit XML reports after running collections for easy review.
  • CI/CD Pipelines: Integrate Newman runs in pipelines (GitHub Actions, Jenkins, GitLab CI) to automate API testing on code changes.
  • Fail Fast: Configure pipelines to fail if any test in the collection fails, preventing faulty deployments.
  • Notifications: Send test results via email or messaging tools (Slack) after runs.
  • Historical Tracking: Store reports in artifact repositories or dashboards for trend analysis.
Best Practices
  • Modular Collections: Organize requests into logical folders for clarity and reuse.
  • Use Environment Variables: Avoid hardcoding URLs and credentials; use environments for flexibility.
  • Write Clear Assertions: Keep test scripts simple and descriptive for easy debugging.
  • Automate Runs: Use Newman in CI/CD to catch issues early and often.
  • Maintain Reports: Keep test reports accessible and readable for the whole team.
Self Check

Where in this folder structure would you add a new environment file for testing the staging environment?

Key Result
Organize Postman collections, environments, and scripts clearly; run collections with Newman; integrate with CI/CD for automated API testing.

Practice

(1/5)
1. What is the main purpose of Running a collection in Postman?
easy
A. To write code for APIs
B. To create new API endpoints
C. To execute a group of API requests in a specific order
D. To delete saved requests

Solution

  1. Step 1: Understand what a collection is

    A collection in Postman is a group of API requests organized together.
  2. Step 2: Purpose of running a collection

    Running a collection means executing all requests in that group one after another automatically.
  3. Final Answer:

    To execute a group of API requests in a specific order -> Option C
  4. Quick Check:

    Running a collection = executing grouped requests [OK]
Hint: Running a collection means running all requests together [OK]
Common Mistakes:
  • Confusing running a collection with creating requests
  • Thinking it deletes requests
  • Assuming it writes code automatically
2. Which of the following is the correct way to start running a collection in Postman?
easy
A. Drag the collection to the trash bin
B. Right-click the collection and select 'Delete'
C. Open the collection and edit the request
D. Click the 'Run' button on the collection

Solution

  1. Step 1: Locate the collection in Postman

    Collections appear in the sidebar with a 'Run' button visible when selected.
  2. Step 2: Starting the run

    Clicking the 'Run' button starts executing all requests in the collection.
  3. Final Answer:

    Click the 'Run' button on the collection -> Option D
  4. Quick Check:

    Run button starts collection execution [OK]
Hint: Look for the 'Run' button to start collections [OK]
Common Mistakes:
  • Choosing delete instead of run
  • Editing requests does not run collection
  • Dragging to trash deletes collection
3. Given a collection with 3 requests, if you run the collection and the second request fails, what happens next?
medium
A. The collection stops running immediately
B. The collection continues to run the third request
C. The collection retries the second request automatically
D. The collection deletes the failed request

Solution

  1. Step 1: Understand default run behavior

    By default, Postman runs all requests in a collection sequentially regardless of individual request failures.
  2. Step 2: Effect of a failed request

    A failed request does not stop the collection run; it moves on to the next request.
  3. Final Answer:

    The collection continues to run the third request -> Option B
  4. Quick Check:

    Collection runs all requests even if one fails [OK]
Hint: Collection runs all requests unless manually stopped [OK]
Common Mistakes:
  • Assuming run stops on failure
  • Thinking Postman retries automatically
  • Believing failed requests get deleted
4. You try to run a collection but get an error saying 'No requests found'. What is the likely cause?
medium
A. The collection is empty with no requests inside
B. You have not selected any environment
C. Postman is offline
D. You clicked 'Run' on a single request instead of collection

Solution

  1. Step 1: Analyze the error message

    'No requests found' means the collection has no requests to run.
  2. Step 2: Check collection contents

    If the collection is empty, running it will cause this error.
  3. Final Answer:

    The collection is empty with no requests inside -> Option A
  4. Quick Check:

    Empty collection = no requests to run error [OK]
Hint: Check if collection has requests before running [OK]
Common Mistakes:
  • Confusing environment selection with requests
  • Assuming offline causes this error
  • Thinking running single request triggers this
5. You want to run a collection multiple times with different data sets for each run. Which Postman feature helps you do this efficiently?
hard
A. Using a data file with the Collection Runner
B. Manually editing each request before running
C. Running each request separately
D. Duplicating the collection for each data set

Solution

  1. Step 1: Identify the need for multiple data sets

    Running the same collection with different inputs requires data-driven testing.
  2. Step 2: Use Collection Runner with data files

    Postman allows uploading CSV or JSON files to run collections multiple times with varied data.
  3. Final Answer:

    Using a data file with the Collection Runner -> Option A
  4. Quick Check:

    Data files + Collection Runner = multiple runs with different data [OK]
Hint: Use data files in Collection Runner for repeated tests [OK]
Common Mistakes:
  • Editing requests manually wastes time
  • Running requests separately is inefficient
  • Duplicating collections is unnecessary