Saturday, September 14, 2019

api testing - postman

https://blog.getpostman.com/2017/07/28/api-testing-tips-from-a-postman-professional/
  • Rembember to Save before exit
  • Variable
1. Collection level, C level: pm.collectionVariables.get("variable_key");pm.collectionVariables.set("variable_key","value");
2. Environment Level: pm.environment.get("variable_key");pm.environment.set("variable_key","value");
3. Global Level: pm.globals.get("variable_key","value");pm.globals.set("variable_key","value");

pm.variables.get(); to get the variable value
  • match with soap UI level
Project->Collection
Test Suite-> Folder Resources, etc
Test Case-> Folder Endpoint
Test Steps->Request
  • Organize tests into folders
As your API grows in complexity, it will become important to organize your tests so they make sense and can be found easily. I suggest that you use folders to group requests by 
Collection
resource
test suite
workflows.
  •  maintain separate collections for testing and documentation
  • Data driven csv file,json file
Collection run, load data
  • Script: Javascript. On each level
Prerequest script: Run before request. Dynamically set or change variables.
Test: Run after getting response. To Validate the result.

  • How to chain API requests
Get data from one API and refer in another API

Environment Variable
pm.environment.set("key",value)

var jsonData = JSON.parse(responseBody);
pm.environment.set("key", jsonData.key);

output variable on Console
console.log(pm.environment.get("xxx"))

  • Run post from command line

1. Check if node.js and npm is already installed"node -v" "npm -v")
2. Install node.js and npm
3. Install NewMan ("npm intall -g newman")
4. Export collection as Json file
5. newman run colllection.json

Go to collection folder
npm run collection.json -e environment.json -r xxx.html
  • Run Postman in Jenkins
1.Setup a new job item "Postmanrun" in Jenkin
2.Build -> running bat, or shell script (adding command for running newman)
3.Apply, Save
4.Run the Job
  • JSON Schema validation


  • reuse code



  • Issues:

When I parse this little piece of JSON

{ "value" : 9223372036854775807 }
that's what I get

{ hello: 9223372036854776000 }
Is there any way to parse it properly?



In JavaScript, one has at most 53 bits for integers. This blog post explains how to work with large integers, by encoding them in strings.

1) Use a parsing library that supports bignumbers
2) Treat numbers as strings





No comments:

Post a Comment

API interview questions

  https://www.katalon.com/resources-center/blog/web-api-testing-interview-questions/ Top 50+ Web API Testing Interview Questions [Ultimate l...