Receiving the Postman Collection Report with Newman.

Receiving the Postman Collection Report with Newman.

In this article, I will explain how to run postman collection and get reports using newman. First of all, I want to tell you why we may need this. Postman gives us the right to run collection 25 times in its free version. You may have already exhausted this right like me.

Secondly, you may want to receive your postman reports in a format that is visually legible and useful for your team members to use for review and debugging.

If these reasons are enough for you, let's get started.

First of all, since newman will run on node.js, we will make the necessary installation. After going to the relevant page, we download the necessary installation file.

I recommend using one of the lts versions here otherwise you may encounter errors. After downloading the file, you can follow the installation steps. It will set the environment variables itself.

Now that the installation is complete, we open the console that will type node.js command prompt in the windows search box.

To the screen that welcomes us;

npm install -g newman

where the -g parameter indicates that the installation is global.

The required installation will be completed and we check that the version is installed by typing newman -v.

Now we will install the node module required to receive reports:

npm install -g newman-reporter-htmlextra

Now that the necessary installations are ready, we need to save the postman collections in a folder. For this, we will export the related collection in Potman. I select the three dots next to Collection and export.

To avoid problems I choose v2.1 and save it in a folder where I will run my tests.

I will also do the same for the enviroment I used in my project;

Now I need to run my project with the required token values. For this I go to the directory where my files are and open the terminal with a right click.

I will type the necessary command in the terminal that opens. To avoid getting an authorization error, I do the token declaration as shown as key value.

newman run Edulog.postman_collection.json -e QAT2.postman_environment.json -r htmlextra --env-var studentToken=eyJhbGciOiJIwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwikleanr        

Here he is;

  • newman run The command used to start Newman.
  • Edulog.postman_collection.json: Path to our Postman collection file to run.
  • -e QAT2.postman_environment.json: Path to our Postman environment file to run.
  • -r htmlextra: will generate the Newman report in HTML format and will use the “htmlextra” report format.
  • --env-var studentToken=...: Specifies the “studentToken” environment variable to be used during the run.

If a specific folder will be run, you can add --folder “yourfoldername” at the end.

Collection will be run in the background and will give us our report in the folder named newman in the directory we are working in.

Here we see a summary of our report, but there is quite detailed information about the report.

We expand the field for detailed information about the requests executed under the relevant folder.

I hope it was useful.

G?ksel ?EL?K

Software Test Engineer ISTQB? Certified

9 个月

??????

回复
Hakan Kara

Software Test Engineer

10 个月

???

回复

要查看或添加评论,请登录

mustafa livdemirci的更多文章

社区洞察

其他会员也浏览了