Skip to main content

Posts

Showing posts from September, 2020

Steps to execute postman collection through newman

  Here is what you need to do to start executing the postman collection through newman on your system: 1. Install NodeJS – https://nodejs.org/en/download . Click on the 32-bit or 64-bit Windows Installer package, depending on your machine configuration. Skip this if NodeJS/npm is already installed on your system. 2. Open a command prompt, and type “node -v” and "npm -v". These commands should work and provide version number if nodeJS installation is successful. 3. Run this command to install newman:   npm install -g newman 4. Install npm package newman-reporter-htmlextra for creating reports.   npm install -g newman-reporter-htmlextra 5. Pull/Export the collection, environment json (if any), test data csv (if any) files from the Postman UI or code repo (git) to your local and run this command through the folder on your local where you have these files: Command where you have collection json and environment json file : newman run "<<your_collectio...

Tips and tricks for automation using Postman/Newman

   1. How do we run multiple newman/postman collections sequentially (back to back) at one run ? Batch running multiple newman/postman test collections : Create a batch file like this and run: call newman run Collection1.postman_collection.json -e qa1.postman_environment.json -r htmlextra --reporters cli,junit,htmlextra --reporter-htmlextra-export TestReport1.html -d TestData1.csv call newman run Collection2.postman_collection1.json -e qa2.postman_environment1.json -r htmlextra --reporters cli,junit,htmlextra --reporter-htmlextra-export TestReport2.html -d TestData2.csv   Side note : Give a shot to https://medium.com/@mnu/run-multiple-postman-collection-in-parallel-stress-ee20801922ed in case you would like to run it in parallel (P.S. haven’t tried this yet)   2. How can we set environment variable based on another environment variable value ? Like for QA1, we need accountNo say "123" but for QA2, we need accountNo say "345", etc.   pm.tes...

Best practices for API automation using Postman

1. Always use Collections and organize tests into folders for testing : Even Though the collection is the top-level of organization, we should have folders that can group together related to requests or demonstrate a detailed workflow. As our API grows in number and complexity, it will become important to organize our tests so they make sense and can be found easily. Therefore, we suggest using folders/sub-folders to group requests by resource, module type, test suite, and workflows. P.S. If require, we can run specific folder(s) inside a collection using “ –folde r ” argument. 2) Use global/environment/collection variables :  Postman also allows us to store data from previous tests into global/collection variables. These variables can be used exactly like environment variables. For example, there is an API that requires data received from another API ( chaining/correlation ). We can store the response attribute (or part of the response) and use that as part of a request ...

Azure DevOps Postman/Newman HTML Report

 In Azure DevOps, if you don't want JUnit Test results and like to have a HTML Report (htmlextra) that newman provides which is very neat and comprehensive, go for this FREE extension: https://marketplace.visualstudio.com/items?itemName=MaciejMaciejewski.postman-report   This lets you create a task for publishing newman HTML Reports in your pipeline into Azure Storage(like shown below in Image 1). And then, embedded reports can be viewed as a tab in Build and Release result page (like shown below in Image 2). Plus, there is an option to download the reports from the same tab.