# Single test data file for all needs?

**URL:** <https://community.postman.com/t/single-test-data-file-for-all-needs/27309>\
**Category:** Help Hub\
**Tags:** newman-project, tests, jsondatafile, data-driven\
**Created:** [August 30, 2021, 9:32pm UTC](https://community.postman.com/t/single-test-data-file-for-all-needs/27309 "2021-08-30T21:32:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jprealinib2b](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@jprealinib2b](https://community.postman.com/u/jprealinib2b)\
**Post date:** [August 30, 2021, 9:32pm UTC](https://community.postman.com/t/single-test-data-file-for-all-needs/27309/1 "2021-08-30T21:32:10Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

_My question_:

I am building a test suite with Postman and Newman runner being executed from Octopus. We have different scenarios and almost all of them need to be data-driven. The way our CI/CD pipeline works involves a yml file with our test “definitions”, basically a json from which the runner gets information of what collection to run, optionally a folder to execute tests from, and a data file to use…

Since we have many different scenarios, it would be necessary to group the tests in many subfolders in order to user a different test data file for each folder, thus creating a lot of definitions in my yml file, and I suspect that causes too much overhead on the overall testing time… So… I was thinking that if I could just run all the tests with a single test-data file which would include a collection of objects for each need, and then preprocess it before each group of tests to extract the desired object collection and use it for the tests inside that folder, that could help a lot…

like this: test-data.json

```auto
[
   {
      "Clients":[
         {
            "ClientName":"John"
         },
         {
            "ClientName":"Peter"
         }
      ]
   },
   {
      "Suppliers":[
         {
            "SupplierName":"George"
         },
         {
            "SupplierName":"Robert"
         }
      ]
   }
]

```

And then, in folder for Clients test, in a pre-request script I could extract from the data file the Clients collections, and use that for the tests… and so on

Could something like this be achievable?

Thanks

---

<div class="post-metadata">

**Author:** ![kitty-garrison](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kitty-garrison/32/27117_2.png) [@kitty-garrison](https://community.postman.com/u/kitty-garrison)\
**Post date:** [August 31, 2021, 9:55pm UTC](https://community.postman.com/t/single-test-data-file-for-all-needs/27309/2 "2021-08-31T21:55:46Z")

</div>

So, I have only used CSVs for data driven tests but this would be my solution to different runs from the same data file but with different data for each test.

I would lay out my CSV as shown in the image, then I would use a conditional such as

```auto
const isLastTest = pm.variables.get("isLastIterationOfTest1").toUpperCase() === "TRUE" ;
if(isLastTest){
  postman.setNextRequest(null)
}

```

so that data sets with differing numbers of iterations can be ended at the last test defined in the data.

 ![Screen Shot 2021-08-31 at 5.54.34 PM](https://us1.discourse-cdn.com/getpostman/original/2X/e/e30104d3f8e810fa0fe5bdcc83b1f7cff0b72e86.png)

Maybe you can fashion something similar with your JSON file.
