postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.84k stars 839 forks source link

Not executing all folders using newman command #13207

Closed praveenrtzen closed 2 weeks ago

praveenrtzen commented 2 weeks ago

Is there an existing issue for this?

Describe the Issue

I have collection which has 8 folder and sub-folders inside those. when I'm executing this collection ,only 6 folders are getting executed and not remaining 2. Not sure why this is happening, I have multiple collections, only one collection have this problem. Folder structure is correct and everything seems fine.

Steps To Reproduce

this is my function

async executeNewman(serviceName) => {
        var total_assertions = 0;
        var failed_assertions = 0;
        try {
            const collectionPath = await Utils.getCollectionPath(serviceName);
            const environmentPath = await Utils.getCollectionEnvFilePath(serviceName);
            const globals = Utils.getGlobalEnvFile();
            const { summary } = await new Promise((resolve, reject) => {
                newman.run({
                    collection: collectionPath,
                    environment: environmentPath,
                    globals: globals,
                    reporters: ['htmlextra', 'cli'],
                    reporter: {
                        htmlextra: {
                            export: Utils.getReportsPath(),
                        },
                    },
                    exportEnvironment: environmentPath
                }, function (err, summary) {
                    if (err) {
                        reject(err);
                    } else {
                        resolve({ summary });
                    }
                });
            });
            total_assertions = summary.run.stats.assertions.total;
            failed_assertions = summary.run.stats.assertions.failed;

            console.log("total_assertions : " + total_assertions);
            console.log("failed_assertions : " + failed_assertions);
        } catch (error) {
            console.error("Error running Newman:", error);
        }
    }

Screenshots or Videos

No response

Operating System

macOS

Postman Version

11.10.1

Postman Platform

Postman App

User Account Type

Signed In User

Additional Context?

No response

DannyDainton commented 2 weeks ago

Hey @praveenrtzen

Are you able to run only that single Collection with Newman to debug this further?

Does the Collection contain any setNextRequest() statements at only level?

praveenrtzen commented 2 weeks ago

Hi,

I have collection something like this collection ---- setup
---- folder1 (having apis and some of them have setNextRequest in post scripts) ---- folder 2
   --- sub folder 1
--- sub folder 2
---- folder 3 --- sub folder 1
   --- sub folder 2
---- folder 4

---- folder 5 | ---- folder 6

and here is function which will execute this collection

async test(serviceName) => {
var total_assertions = 0;
var failed_assertions = 0;
try {
const collectionPath = <collection_path>;
const environmentPath = <env_file_path>;
const globals = <global_file_path>;
const { summary } = await new Promise((resolve, reject) => {
newman.run({
collection: collectionPath,
environment: environmentPath,
globals: globals,
reporters: ['htmlextra', 'cli'],
reporter: {
htmlextra: {
export: <report_folder_path>,
},
},
exportEnvironment: environmentPath
}, function (err, summary) {
if (err) {
reject(err);
} else {
resolve({ summary });
}
});
});
total_assertions = summary.run.stats.assertions.total;
failed_assertions = summary.run.stats.assertions.failed;

console.log("total_assertions : " + total_assertions);
console.log("failed_assertions : " + failed_assertions);
} catch (error) {
console.error("Error running Newman:", error);
}
}

folder 1 to 4 are executing as expected but folder 5 and 6 are not executing and cannot see in newman report.

I have around 10 collections like this, but there is no problem with other collection files, I'm facing problem with this collection only.

DannyDainton commented 2 weeks ago

What does the last request in Folder 4 contain? Can you share the post-response script?

When you run that Collection in the Collection Runner, does it also not run those folders?

The issue would be in that Collections Folders or Requests - Something, likely a script, will be in there controlling the workflow. Providing more details about the Collection will help here.

praveenrtzen commented 2 weeks ago

I found one issue in my script only , I will fix it from my end and sorry for this. Thank you so much for your support.

On Thu, Oct 17, 2024 at 8:40 PM Danny Dainton @.***> wrote:

What does the last request in Folder 4 contain? Can you share the post-response script?

When you run that Collection in the Collection Runner, does it also not run those folders?

The issue would be in that Collections Folders or Requests - Something, likely a script, will be in there controlling the workflow. Providing more details about the Collection will help here.

— Reply to this email directly, view it on GitHub https://github.com/postmanlabs/postman-app-support/issues/13207#issuecomment-2419819096, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7XKWEJ24SHFWHV3URKV42TZ37HNBAVCNFSM6AAAAABQDHSNPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJZHAYTSMBZGY . You are receiving this because you were mentioned.Message ID: @.***>

DannyDainton commented 2 weeks ago

Just for clarity - What was the issue?

praveenrtzen commented 2 weeks ago

There was a setNextRequest(api1) line, and this api1 doesn't exist anymore. so I removed it and now it's working fine.

On Thu, Oct 17, 2024 at 9:18 PM Danny Dainton @.***> wrote:

Just for clarity - What was the issue?

— Reply to this email directly, view it on GitHub https://github.com/postmanlabs/postman-app-support/issues/13207#issuecomment-2419909332, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7XKWEJFD6VLFVTC7YRKAILZ37L4DAVCNFSM6AAAAABQDHSNPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJZHEYDSMZTGI . You are receiving this because you were mentioned.Message ID: @.***>

DannyDainton commented 2 weeks ago

Awesome. I'll close out this issue.

praveenrtzen commented 2 weeks ago

Yes please.

On Thu, Oct 17, 2024 at 9:23 PM Danny Dainton @.***> wrote:

Awesome. I'll close out this issue.

— Reply to this email directly, view it on GitHub https://github.com/postmanlabs/postman-app-support/issues/13207#issuecomment-2419920165, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7XKWEPAP6O66QTBPX3VVY3Z37MN3AVCNFSM6AAAAABQDHSNPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJZHEZDAMJWGU . You are receiving this because you were mentioned.Message ID: @.***>