postman+newman+Jenkins automated test interface generates test reports, including errors and problems encountered

In the previous blog, I wrote about using newman to generate postman. Now let's see how to deploy newman to Jenkins.
Since my test environment has already installed Jenkins and node, I won't go into details.
This blog mainly explains how to execute the newman command with Jenkins

1. Install Jenkins in the Linux environment

Here is a link
to other hotspots to install Jenkins. Reference link: https://blog.csdn.net/zjh_746140129/article/details/80835866

Two, install node.js in the linux environment

Reference link https://blog.csdn.net/sinat_37390744/article/details/77413673
running

node -v

To see if the installation is successful
Insert picture description here

Three, install newman

Because newman is a nodejs library launched by Postman, nodejs must be installed to run it, and newman can also be installed directly with npm

npm install -g newman

As shown in the figure below, the installed version of newman will appear after the installation, and the path where the installation is located. The
Insert picture description here
installed newman will
run in the folder where npm is located.

newman -v

To check if the installation is successful,
Insert picture description here
create a soft connection for newman

ln -s /var/lib/jenkins/env/node-v10.4.1-linux-x64/bin/newman /usr/bin/newman

Install html

npm install -g newman-reporter-html

Fourth, export the collection file from postman

Click the three dots on the right side of the use case set and
Insert picture description here
click Export
Insert picture description here

Five, run newman directly in linux

Put the exported json file into the Linux environment, including use cases and environment variables.
Insert picture description here
Execution

newman run 1.json -g env.json

The result is as shown in the figure below.
Insert picture description here
Note : It depends on which path the exported json file is placed in, and the running path must be correct. I put it in the root directory and run it under the root directory.

Generate html file

newman run 1.json -g env.json -r html

The generated html file is in the newman folder in the same directory

Six, run the script in Jenkins

Open Jenkins to
create a free-style project
Insert picture description here
, select Execute shell
Insert picture description here
in the build, and enter in the command

cd /
newman run 1.json -g env.json
Insert picture description here

In fact, just in command here linux operating environment as
Click Save
to enter the project, click Bulid Now
Insert picture description here
I encountered a problem during the execution of
that has been given in Jenkins Lane: / usr / bin / env: node: No such file or directory
Insert picture description here
This the problem is a result of the newman script because the top of the node position
Insert picture description here
should change the path node where files are located
Insert picture description here
at this time to go perform Jenkins project
will succeed you, as shown below
Insert picture description here
each time very happy and all learning experiences encountered Write the error on the blog and share it with everyone~ The
next step is to configure Jenkins to automatically send the test report email

Guess you like

Origin blog.csdn.net/shenshenruoxi/article/details/106189933