Bird
Raised Fist0
Postmantesting~15 mins

Collections and folders in Postman - Build an Automation Script

Choose your learning style10 modes available
Create a Postman collection with folders and add requests
Preconditions (2)
Step 1: Click on 'New' and select 'Collection' to create a new collection named 'User API Tests'
Step 2: Inside the 'User API Tests' collection, create a folder named 'User Creation'
Step 3: Add a POST request to the 'User Creation' folder with URL 'https://api.example.com/users'
Step 4: Set the request body to JSON with fields 'name' and 'email'
Step 5: Save the request with the name 'Create User'
Step 6: Create another folder inside the collection named 'User Retrieval'
Step 7: Add a GET request to the 'User Retrieval' folder with URL 'https://api.example.com/users/{{userId}}'
Step 8: Save the request with the name 'Get User'
Step 9: Verify that the collection contains two folders each with one request
✅ Expected Result: The 'User API Tests' collection contains two folders named 'User Creation' and 'User Retrieval'. Each folder contains one request named 'Create User' and 'Get User' respectively with correct URLs and request types.
Automation Requirements - Postman Collection Runner with Newman
Assertions Needed:
Verify collection structure has two folders
Verify each folder contains exactly one request
Verify request methods and URLs are correct
Best Practices:
Use Postman Collection JSON format for defining collections and folders
Use descriptive names for collections, folders, and requests
Use variables for dynamic parts of URLs
Validate collection structure programmatically before running tests
Automated Solution
Postman
{
  "info": {
    "name": "User API Tests",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "User Creation",
      "item": [
        {
          "name": "Create User",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"name\": \"John Doe\", \"email\": \"john@example.com\"}"
            },
            "url": {
              "raw": "https://api.example.com/users",
              "protocol": "https",
              "host": ["api", "example", "com"],
              "path": ["users"]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "User Retrieval",
      "item": [
        {
          "name": "Get User",
          "request": {
            "method": "GET",
            "url": {
              "raw": "https://api.example.com/users/{{userId}}",
              "protocol": "https",
              "host": ["api", "example", "com"],
              "path": ["users", "{{userId}}"]
            }
          },
          "response": []
        }
      ]
    }
  ]
}

The JSON defines a Postman collection named User API Tests. It has two folders: User Creation and User Retrieval.

Each folder contains one request. The User Creation folder has a POST request to create a user with a JSON body. The User Retrieval folder has a GET request with a variable {{userId}} in the URL.

This structure matches the manual test case steps and expected results. Using this JSON, you can import the collection into Postman or run it with Newman.

Common Mistakes - 4 Pitfalls
Not using folders inside the collection
Hardcoding dynamic values instead of using variables
Missing Content-Type header for POST requests
Incorrect JSON formatting in request body
Bonus Challenge

Now add data-driven testing by running the 'Create User' request with 3 different sets of user data

Show Hint

Practice

(1/5)
1. What is the main purpose of a Collection in Postman?
easy
A. To create user accounts in Postman
B. To store environment variables
C. To write JavaScript code for tests
D. To group API requests and tests together for better organization

Solution

  1. Step 1: Understand what a Collection is

    A Collection in Postman is used to group API requests and tests logically.
  2. Step 2: Differentiate from other features

    Environment variables and user accounts are separate features, not Collections.
  3. Final Answer:

    To group API requests and tests together for better organization -> Option D
  4. Quick Check:

    Collection = Group API requests [OK]
Hint: Collections group requests; folders organize inside collections [OK]
Common Mistakes:
  • Confusing collections with environments
  • Thinking collections store user data
  • Mixing collections with test scripts
2. Which of the following is the correct way to create a folder inside a Postman collection?
easy
A. Drag and drop requests outside the collection
B. Right-click the collection and select 'Add Folder'
C. Click 'New' and select 'Environment'
D. Use the 'Runner' tab to create folders

Solution

  1. Step 1: Identify folder creation method

    Folders are created by right-clicking a collection and choosing 'Add Folder'.
  2. Step 2: Eliminate incorrect options

    Creating environments or using Runner does not create folders.
  3. Final Answer:

    Right-click the collection and select 'Add Folder' -> Option B
  4. Quick Check:

    Create folder = Right-click collection [OK]
Hint: Right-click collection to add folder quickly [OK]
Common Mistakes:
  • Trying to create folders from the Runner tab
  • Confusing environments with folders
  • Dragging requests outside collections
3. Given a collection with two folders named Users and Orders, which statement is true about running tests in Postman?
medium
A. You can run all requests in the collection or just one folder at a time
B. You must run each request individually; folders cannot be run
C. Folders run automatically when you open the collection
D. Running a folder deletes all requests inside it

Solution

  1. Step 1: Understand running collections and folders

    Postman allows running all requests in a collection or just those inside a specific folder.
  2. Step 2: Verify incorrect options

    Folders do not run automatically, and running does not delete requests.
  3. Final Answer:

    You can run all requests in the collection or just one folder at a time -> Option A
  4. Quick Check:

    Run collection or folder = possible [OK]
Hint: Run entire collection or single folder as needed [OK]
Common Mistakes:
  • Believing folders run automatically
  • Thinking folders cannot be run
  • Confusing running with deleting requests
4. You created a folder inside a collection but it does not appear in the sidebar. What is the most likely cause?
medium
A. The folder was not saved properly after creation
B. Postman does not support folders inside collections
C. You need to restart Postman to see new folders
D. Folders only appear after running the collection

Solution

  1. Step 1: Check folder creation process

    If a folder does not appear, it is often because it was not saved or confirmed properly.
  2. Step 2: Exclude other causes

    Postman supports folders, no restart needed, and folders appear immediately, not after running.
  3. Final Answer:

    The folder was not saved properly after creation -> Option A
  4. Quick Check:

    Unsaved folder = not visible [OK]
Hint: Always save folder after creating to see it [OK]
Common Mistakes:
  • Assuming Postman lacks folder support
  • Restarting Postman unnecessarily
  • Expecting folders to appear only after running
5. You want to organize a large API test suite in Postman with multiple related requests. Which approach best uses collections and folders for clarity and reusability?
hard
A. Create one folder per API and put all requests directly inside it without collections
B. Put all requests in a single collection without folders to avoid complexity
C. Create one collection per API, then use folders inside it to group related requests by feature
D. Create separate collections for each request to isolate tests

Solution

  1. Step 1: Understand best organization practice

    Using one collection per API keeps tests grouped logically, and folders inside help organize by feature.
  2. Step 2: Evaluate other options

    Folders cannot exist without collections, too many collections reduce reusability, and no folders cause clutter.
  3. Final Answer:

    Create one collection per API, then use folders inside it to group related requests by feature -> Option C
  4. Quick Check:

    Collection + folders = best organization [OK]
Hint: Use collections for APIs, folders for features inside [OK]
Common Mistakes:
  • Trying to create folders without collections
  • Overusing collections for each request
  • Avoiding folders causing messy tests
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard