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