Dynamic request collection

Hi all,

I’m trying to use Newman with CI.
After I read the Newman guide, I found Newman only can run with a collection.
But I have a question below.

For example, there have five requests. A, B, C, D, E
In different scenario may have different combination with request.
Scenario 1 : First call A request then call B then call C
Scenario 2 : First call A request then call C then call D
Scenario 3 : First call A request then call C then call E

The worst way to use Newman with CI is create three collection.
First collection have three request (A, B, C)
Second collection have three request (A, C, D)
Third collection have three request (A, C, E).

But there have a problem, if my request A API format change I need to change three request in these collection.

Is there a dynamic way to build request collection items?

Best regards,
Ziv

Hi @ZivWu

I think you would have to use the postman.setNextRequest("request_name"); option and build conditions into your test tab.

Example;
If request A returns value X then run request C
else run request D

You can find more info on request workflows here:

Hi @w4dd325

Yes, I’m useing this way currently. But it will make my postman script very hard to maintain.

My way is use a variable to set current scenario number.
Then use the setNextRequest base on current scenario number.
In A request postman script will check current scenario number and setNextRequest.
Just like if current scenario number is 1 request A next go to request B, If current scenario number 2 request A next go to request C.
In the request B also need check the current scenario number to setNextRequest to C.
In the request C need check the current scenario number and setNextRequest to request A and set current scenario number to 2.

In this way will make my request postman script hard to maintaine.(very long and worse readable)
Also if I need to add a new scenario I have to edit many request’s postman script.

I’m searching about is there a way use program to build collection content?

Best regards,
Ziv

Hi all,

If you have same question like me.
I found a better way. Introduction | Postman Labs Docs
Postman flows is beta currently and it will support CI (newman)

Best regards,
Ziv