Postman as QA automation tool
We all know “postman” we do use it as API test tool for the QA department. Mostly for straightforward non-automative solutions. But postman facilitates for very interesting integrations and automation like bulk run, console execution, runner support & CI (continuous integrations). Here we will be talking about Postman software automation, and we will showcase some test cases examples.
How to hit multiple requests in postman? What are we trying to do?
1. Test API /Rest: Straightforward run and check individually: It’s Basic 🙂
2. Write QA test cases over your request: Yes. you can refer this for syntaxes and method. : Link
3. Test multiple requests as bulk execution: Yes. Postman support for this. You can create a test suite and run. You will have a nice dashboard too.
Today we will see, postman automation scripts
Now once the latest cases are built, we need to pass it Newman to run these QA scripts from the command line. The basic idea of running these tests using the command line is that we can pass them to Jenkins further, which in return will run the test cases periodically, with this intention to run the test cases in Newman, we need to export the test scripts and other information like URL, also the headers, and many other items from the postman in JSON format.
Download environment and global variable information
1. In postman, click on the (*) located at the top right section.
2. Click on Manage Environment
3. Now click on download icon placed against the environment name
4. Save the JSON on the same location where the collection was saved
5. Now to download global variables, click on the “Globals” button placed at the bottom of the pop-up.
6. Click on “Download as JSON” button.
7. Save the JSON on the same location as others.
Now we need to generate json for test suit
Steps to export JSON for newman:-
1. In postman, under Collections section, select the required collection.
2. Click on Export as shown in the image below.
3. Select “Collection v2”
4. Click on Export
5. Save this JSON
Now it’s time to run our test cases from the command line
Steps to run test cases from the command line:-
2.Now reach to the folder where your JSON is saved
3.Now hit command as below
newman run Test_Collection.postman_collection.json -e Environment.postman_environment.json -g globals.postman_globals.json -d demoData.csv --reporters cli,html
Now you will see this result in the console
And you can get the HTML report (Detailed) in the same folder. Tadaaa !!
Now you can customize this structure for the automation project.
Actually, we can do two things now.
* You can manage repetition of the API’s. for performance benchmarking
* Check integration with Jenkins
Related Topics By ZIWO: