Initiate another environment from tests in the same collection

Have a collection with multiple requests and tests.
But I had to add a new folder with some tests that requires to be initiated with a different environment that the other tests in the same collection uses.

Is there any way to call the other environment to be applied only for the folder/tests or do I have to split this up in it’s own collection?

Can you explain your use case? Why do you need to do this?

Maybe we can come up with a different approach.

Yeah sure.

I have a set of tests which are in one huge collection, separated in different folders. The tests in this collection are initiated on one specifig environment, let’s call it env1.

But now I have to add some other tests to this collection, but these tests won’t run on env1 due to our test environment setup so I need to run them on a different environment, let’s call this env2.

So is there any possibilities to actually point the new tests and say that they should run on pm.environment.name === env2 instead of env1 or do I have to actually create an own collection and initiate them as usual with newman run -e

Why do you need the different environment? Is it different base urls?

Is it possible to move these environment variables to collection variables instead?

Yes, it is different base urls.
I could try to move them into collection variables like you suggested, thanks.

1 Like