Execute postman tests in a folder

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

@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 …

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 …

@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.

Here is what that run looks like …

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

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