Postman as QA automation tool

25 - Aug - 2019 DeveloperIntegrationsQA

We all know “postman” we do use it as API test tool. Mostly for straight forward non-automative solutions. But postman facilitates for very interesting integrations like bulk run, console execution, runner support & CI (continuous integrations).

What are we trying to do?

1. Test API /Rest: Straightforward run and check individually: It’s Basic 🙂

2. Write 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,

Now once the test cases are built, we need to pass it newman to run these 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. Now, to run the test cases in Newman, we need to export the test scripts and other information like URL, headers etc 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:-

1.Open CMD

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 your project.

Actually, we can do two things now.

* You can manage repetition of the API’s. for performance benchmarking

* Check integration with Jenkins

References :

Share this

You may also like

22 - Nov - 2019 DeveloperIntegrationsQA
26 - Sep - 2019 DeveloperIntegrationsQA
16 - Sep - 2019 DeveloperIntegrationsStartUp