# Distinguish collection run from individual request in test

**URL:** <https://community.postman.com/t/distinguish-collection-run-from-individual-request-in-test/56439>\
**Category:** Help Hub\
**Tags:** tests, collections\
**Created:** [January 10, 2024, 9:16pm UTC](https://community.postman.com/t/distinguish-collection-run-from-individual-request-in-test/56439 "2024-01-10T21:16:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![meredithalcorn](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@meredithalcorn](https://community.postman.com/u/meredithalcorn)\
**Post date:** [January 10, 2024, 9:16pm UTC](https://community.postman.com/t/distinguish-collection-run-from-individual-request-in-test/56439/1 "2024-01-10T21:16:25Z")

</div>

**Goal**  
I would like to distinguish between a collection runner request and an individual request using “Send” from within the test scripts.

**Use case**  
For tests run with the collection runner, I pull data into the pre-request script from a predefined environmental variable, manipulate it, and then make an assertion on that data in the test script. When I run an individual request, I don’t want that data to be set in the pre-request script or for these tests to run.

One idea that I had was to see if I could differentiate these requests by checking if setNextRequest was defined in the collection runner and undefined in the individual request. I found that by console logging postman.setNextRequest() in the test script returned undefined in both cases.

I got this idea from the documentation: `postman.setNextRequest()` is intended for use when running a collection using the Collection Runner, the Postman CLI, or Newman. It has no effect when you run a request using **Send**.

Do you have a link to the documentation for the postman object itself, and/or an idea about how my goal to distinguish between them can be achieved?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 11, 2024, 10:49am UTC](https://community.postman.com/t/distinguish-collection-run-from-individual-request-in-test/56439/2 "2024-01-11T10:49:27Z")

</div>

[Determining if a test was run from a Collection or Send - 🙋 Help - Postman Community](https://community.postman.com/t/determining-if-a-test-was-run-from-a-collection-or-send/54572)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [January 14, 2024, 10:49am UTC](https://community.postman.com/t/distinguish-collection-run-from-individual-request-in-test/56439/3 "2024-01-14T10:49:42Z")

</div>

Closed on January 14, 2024, 10:49am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
