Wednesday, March 29, 2017

REST API testing tool



1. Install json2csv for generating csv from sample json file
$npm i -g json2csv

2. Install csv-split to generate multiple csv file from one csv file
$npm i -g csv-split


3. Install csvtojson to convert csv files to json
npm i -g csvtojson
4. Save sample json in file example: sample.json

3. Run command to generate csv from sample file
$json2csv -i sample.json -o sample.csv -F
$json2csv -i <sample json file> -o <output csv file> -F (to flatten hierarchal json in single line )

5. Create rows for various test cases in csv file

6. Generate multiple csv files from test case file, which is csv file
$csv-split -i sample.csv -o sample -b name
$csv-split -i <csv file> -o <folder name> -b <file name prefix from csv header>

6. Convert CSV files to json files
$csvtojson sample/sample1.csv > sample/sample1.json


https://github.com/zeMirco/json2csv
https://www.npmjs.com/package/csvtojson
https://www.npmjs.com/package/csv-split

No comments:

Post a Comment