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 APIMEDIUM - Balance Check APILOW - Fetch Profile
Environment Variable for Execution Control
| Key | Value Examples |
|---|---|
| runPriority | CRITICAL / MEDIUM,CRITICAL / LOW / ALL |
ALL– run all testsCRITICAL– run only critical testsMEDIUM,CRITICAL– run both medium and criticalLOW– 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!