newman -v):Hey @Freakishmahesh, postman.setNextRequest can help achieve request skipping as well. Consider the following workflow:
postman.setNextRequest("C");.B would never be run.This will not work if you wish to skip the first / last request in a collection, however.
@Freakishmahesh How did this go for you? :thinking:
@kunagpal Thank you for words. As you said, cannot skip first/last in a collection. Even if setNextRequest("C"), I cannot see anywhere in the reports that Request B has skipped :(
That's odd. How exactly did you use postman.setNextRequest? Please check out the following example collection in Newman, and the Postman collection runner:
{
"variables": [],
"info": {
"name": "skipped-requests",
"_postman_id": "3ae56cc9-f7dd-f70d-f1c0-45d19fbf32e3",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "A",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"postman.setNextRequest(\"C\");"
]
}
}
],
"request": {
"url": "https://echo.getpostman.com/get?val=a",
"method": "GET",
"header": [],
"body": {
"mode": "formdata",
"formdata": []
},
"description": "This request always runs first"
},
"response": []
},
{
"name": "B",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;"
]
}
}
],
"request": {
"url": "https://echo.getpostman.com/get?val=b",
"method": "GET",
"header": [],
"body": {
"mode": "formdata",
"formdata": []
},
"description": "This request is always skipped in the collection runner / Newman"
},
"response": []
},
{
"name": "C",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;"
]
}
}
],
"request": {
"url": "https://echo.getpostman.com/get?val=c",
"method": "GET",
"header": [],
"body": {
"mode": "formdata",
"formdata": []
},
"description": "This request always runs last"
},
"response": []
}
]
}
I didn't see information about skipped requests details in the command prompt summary . What do I expect is to have, requests count and names of skipped requests.
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ โ executed โ failed โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ iterations โ 1 โ 0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ requests โ 6 โ 0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ test-scripts โ 6 โ 0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ prerequest-scripts โ 0 โ 0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ assertions โ 5 โ 0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโค
โ total run duration: 15s โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ total data received: 3.45KB (approx) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ average response time: 2.3s โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
@Freakishmahesh Well, this would be a good addition to Newman, thanks for bringing this up! :+1:
+1
I don't want to run request C.
How can i do that ?
Req : A, B and C
@kunagpal
@jayanthktn In the test script of request B, you can add the following statement:
postman.setNextRequest(null);
Thanks @kunagpal
This will be taken up as part of execution control support in scripts
How to skip the execution of request A ?
I need to skip request A and B for de 2nd iteration. How can I do it? Please help
Is there a way to skip Req A and Req B for the 2nd iteration and only execute Req C ?
This will be taken up as part of execution control support in scripts
Is there an issue reference that can be shared here to track for support for this feature?
Most helpful comment
How to skip the execution of request A ?