- This is a API test automation tool based on postman,newman and nodejs.
- Using postman and newman we can verify responses and details related to response such as response code , response time.
- But we are not able to capture logs from API module.
- Using this tool we can capture logs if need.
- Easy to add more test cases
- Easy to add test requests (only postman collection and testcase csv addition will give newer test scope)
- Can run in CLI
node -v : v10.23.0
npm -v : 6.14.8
run npm insall in QA-Tools-API-Automation folder
npm install -S newman
npm install -S newman-reporter-htmlextra
npm install read-last-lines --save
npm install -S properties-reader
- Go to
QA-Tools-API-Automation/mock-server
- Run
node runServer.js
- When send requests for mock-server , mock.logs will update for each requests
- Go to
QA-Tools-API-Automation
folder - Remove files in
reports
folder - Set mock-server url properly in
QATool-Conf.json
invalues.value : "http://172.16.3.184:3000"
if need. - Update
QATool-GET-Testcases.csv
as need (can add more test cases or update values for test cases Eg : new username,password and expected results for it). - Run following command
newman run GET-Example/QATool-GET.postman_collection.json -g QATool-Conf.json -d GET-Example/QATool-GET-Testcases .csv -r htmlextra --reporter-htmlextra-export reports/QATool-report.html --reporter-htmlextra-title "QA-Tool Report"
- Go to
reports
folder and openQATool-report.html
in browser and verify all test cases are passed.
- Copy
QA-Tools-API-Automation
folder in to server - Ensure all Pre-requires are installed
- Go to
QA-Tools-API-Automation
folder - Remove files in
reports
andtempcsv
folders and removeindex.html
file. - Set mock-server url properly in
QATool-Conf.json
invalues.value : "http://127.0.0.1:3000"
if need. - Update
QATool-GET-Testcases.csv
as need (can add more test cases or update values for test cases Eg : new username, password and expected results for it). - If need to get logs please add log column in
QATool-GET-Testcases.csv
and add values as follows
- pattern
<module-name>,<log-path>,<number of loglines need to capture>
Eg : if only one moduel log need to capture add as "mock,/home/shehan/QA-Tools-API-Automation/mock-server/mock.logs,1" Eg : if multiple moduel log need to capture add as "mock,/home/shehan/QA-Tools-API-Automation/mock-server/mock.logs,1;mock2,/home/shehan/QA-Tools-API-Automation/mock-server/mock.logs,1" Eg : if no need logs for some cases add as "no"
also add log column number in cloumnNumber=6
in config.properties
8.Update following in config.properties
as needed
data_dir=/home/shehan/QA-Tools-API-Automation dataCSV=GET-Example/QATool-GET.csv JSONcollection=GET-Example/QATool-GET.postman_collection.json globalEnv=QATool-Conf.json cloumnNumber=6
9.Then run node runTests.js
in QA-Tools-API-Automation
folder
10.After finish test execution run node combineReports.js
11.Open index.html
in browser (if copying this back to local machine copy full directory mSpace-LBS-API-Automation-Postman
)
- Import
QATool-GET.postman_collection.json
in to postman - Using Body tab request can change
- Using Tests tab Test scenario can change
Eg : pm.test(testcase + " validate response name",function() { pm.expect(pmresp[0].name).to.eql(pm.iterationData.get("expect_name")); });
- CSV pattern
testcase,username,password,expect_name,expect_usertype,logs
First Copy existing line as bellow (no need heading line just for understanding )
testcase,username,password,expect_name,expect_usertype,logs
Verify_admin_data,admin,123,ADMIN,admin,"mock,/home/shehan/QA-Tools-API-Automation/mock-server/mock.logs,1"
Then Past to new line and update test case as need (no need heading line just for understanding )
testcase,username,password,expect_name,expect_usertype,logs
new_testcase,admin,123,ADMIN,admin,"mock,/home/shehan/QA-Tools-API-Automation/mock-server/mock.logs,1"