# Execute postman tests in a folder

**URL:** <https://community.postman.com/t/execute-postman-tests-in-a-folder/1020>\
**Category:** Help Hub\
**Created:** [February 22, 2018, 12:56am UTC](https://community.postman.com/t/execute-postman-tests-in-a-folder/1020 "2018-02-22T00:56:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SatejMirpagar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/satejmirpagar/32/251_2.png) [@SatejMirpagar](https://community.postman.com/u/SatejMirpagar)\
**Post date:** [February 22, 2018, 12:56am UTC](https://community.postman.com/t/execute-postman-tests-in-a-folder/1020/1 "2018-02-22T00:56:26Z")

</div>

Hi Team,

I have scenario where i want to execute multiple json file using newman.

Is there way I can use regular/wildcard expressions to execute all json in a folder. I have about 50 json in a folder - and i don’t want to execute newman individually for each file.

For eg:  
newman run C:\Test\*.json

Also is there any way I can execute test based on tags  
For eg:

newman run @SmokeTest

This is urgent requirement in the project - so any solution will be appreciated.

Thanks  
SM

---

<div class="post-metadata">

**Author:** ![dhoyt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/dhoyt/32/238_2.png) [@dhoyt](https://community.postman.com/u/dhoyt)\
**Post date:** [February 22, 2018, 4:27pm UTC](https://community.postman.com/t/execute-postman-tests-in-a-folder/1020/2 "2018-02-22T16:27:43Z")

</div>

@SatejMirpagar

As far as I know, newman can only process one collection at a time. Here is overview of what I implemented.

I have a node javascript that uses ‘globule’ to create a file called postman\_collection\_files.txt that lists all my POSTMAN collections, in a directory, that I want to run. That file is used as input to a BAT file that will loop thru the collection file lines and run each collection with newman.

Note: my node javascript also “calls” the BAT file after the list has been created so the whole process is contained in the one node javascript program.

Here is what the list of files in postman\_collection\_files.txt looks like when I process the Regression\_Blockedusers directory …

```auto
1-of-3:../Regression_Blockedusers/RegrBlkUsrs_Add.postman_collection.json
2-of-3:../Regression_Blockedusers/RegrBlkUsrs_Delete.postman_collection.json
3-of-3:../Regression_Blockedusers/RegrBlkUsrs_Get.postman_collection.json

```

The BAT file is called like this … API\_TEST\_NEWMAN.bat -e environment\_file -g global\_file

Here is what the BAT file looks like that will process that file …

```javascript
@echo off
setlocal enableextensions
set count1=0
set "collectionFiles = postman_collection_files.txt"

for /f "tokens=*" %%a in (postman_collection_files.txt) do (
	set /A count1+=1
)

echo. >> CON
echo !!! TOTAL COLLECTIONS = %count1% >> CON
echo -env %2 > api_out.txt
echo !!! TOTAL COLLECTIONS = %count1% >> api_out.txt

for /f "tokens=1,2 delims=:" %%A in (postman_collection_files.txt) do (
	echo. >> CON
	echo Running : %%A : %%B >> CON
	echo ">>> " %%B >> api_out.txt
	newman run %%B %1 %2 %3 %4 --timeout-request 120000 >> api_out.txt
)

```

Finally, I have another node javascript that processes api\_out.txt and displays,  
to the console, what has passed and what has not passed.

I think there is enough here for you to build off of.

---

<div class="post-metadata">

**Author:** ![dhoyt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/dhoyt/32/238_2.png) [@dhoyt](https://community.postman.com/u/dhoyt)\
**Post date:** [February 22, 2018, 4:32pm UTC](https://community.postman.com/t/execute-postman-tests-in-a-folder/1020/3 "2018-02-22T16:32:40Z")

</div>

Here is what that run looks like …

```auto
api_test_blockedusers -ex stage-dev

!!! TOTAL COLLECTIONS = 3

Running : 1-of-3 : ../Regression_Blockedusers/RegrBlkUsrs_Add.postman_collection.json

Running : 2-of-3 : ../Regression_Blockedusers/RegrBlkUsrs_Delete.postman_collection.json

Running : 3-of-3 : ../Regression_Blockedusers/RegrBlkUsrs_Get.postman_collection.json

-------------------------------------------------------------------------------

Regression_Blockedusers/RegrBlkUsrs_Add (1)
  √ TEST PASSED - User blocked - userId : 111807

Regression_Blockedusers/RegrBlkUsrs_Delete (2)
  √ TEST PASSED - response code = 200 - expected responseCode is 200

Regression_Blockedusers/RegrBlkUsrs_Get (3)
  √ TEST PASSED - Got Blocked User - userId : 111811

-- Summary - Regression_Blockedusers ------------------------------------------

ENVIRONMENT : stage-dev.postman_environment.json

!!! TOTAL COLLECTIONS = 3 >>> TOTAL PASSED = 3 >>> TOTAL FAILED = 0

-------------------------------------------------------------------------------
Start Time = 10:51:09.35
End Time = 10:51:27.23
..........................
Elapsed Time : 00:00:17.88

```

---

<div class="post-metadata">

**Author:** ![SatejMirpagar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/satejmirpagar/32/251_2.png) [@SatejMirpagar](https://community.postman.com/u/SatejMirpagar)\
**Post date:** [February 23, 2018, 12:28am UTC](https://community.postman.com/t/execute-postman-tests-in-a-folder/1020/4 "2018-02-23T00:28:02Z")

</div>

Thanks mate, will give it a try!. Appreciate your help on this.
