Implementing Priority-Based Execution Strategy in Postman

Hi everyone,

I’m currently working on implementing a priority-based execution strategy for API automation in Postman. The goal is to selectively execute requests from a large collection (e.g., 5000 requests) based on their criticality.

Request Naming Convention

Each request in the collection is named based on its priority:

  • CRITICAL - Login API
  • MEDIUM - Balance Check API
  • LOW - Fetch Profile

Environment Variable for Execution Control

Key Value Examples
runPriority CRITICAL / MEDIUM,CRITICAL / LOW / ALL
  • ALL – run all tests
  • CRITICAL – run only critical tests
  • MEDIUM,CRITICAL – run both medium and critical
  • LOW – run only low priority tests

Pre-request Script (Used in Every Request)
let runPriority = pm.environment.get(‘runPriority’);
console.log(“Run Priority:”, runPriority);
console.log(“Request Name:”, pm.info.requestName);

// Skip the request if it doesn’t match the desired priority
if (runPriority !== ‘ALL’ && !runPriority.split(‘,’).some(p => pm.info.requestName.includes(p.trim()))) {
pm.execution.skipRequest();
}

Running with Newman (CLI)

To run all tests:

newman run priority_collection.json --env-var runPriority=ALL

To run only CRITICAL tests:

newman run priority_collection.json --env-var runPriority=CRITICAL

Issue I’m Facing

When a request is skipped using pm.execution.skipRequest(), it still appears as passed in the Allure report, which creates confusion in the test summary.

Looking for Suggestions

If anyone has implemented a similar strategy or knows a better approach to handle priority-based execution and reporting (especially with Allure), I’d really appreciate your insights or suggestions.

Thanks in advance!

1 Like

@gourish-mahale
Thank you for your post.
This is an interesting priority based approach.

I believe whether all requests are put on scenarios the pm.execution.skipRequest() shall operate.

Unless all requests are not put on divers scenarios, you may encounter that error.

Again, thank you for your post.