Postman之newman

系列文章目录
1.Postman之安装及汉化基本使用介绍
2.Postman之变量操作
3.Postman之数据提取
4.Postman之pm.test断言操作
5.Postman之newman

Postman之newman

newman可以理解为,没有命令行的postman,把写好的测试脚本直接在命令行中运行,newman依赖于node环境,因此,需要先安装好node再安装newman

1.基础环境node安装

首先通过官网下载node

也可以通过网盘分享的文件下载:node-v22.11.0-x64.msi

链接: https://pan.baidu.com/s/1TbNMD79NbgcTpPjsEi7jbQ?pwd=b6ke 提取码: b6ke

--来自百度网盘超级会员v2的分享

windows下载后,双击文件运行一直下一步,傻瓜式安装即可:

如图:则表示安装成功

1.1.配置环境变量

1.在开始栏中搜索环境变量,点击进入即可

2.双击path,新建环境变量输入:node的安装路径


在cmd命令行中输入:

bash 复制代码
#查看node版本
node -v
#查看npm版本
npm -v
#切换为淘宝镜像,官网镜像下载速度很慢
npm config set registry https://registry.npmmirror.com/

如图即可:

1.2.安装newman和html报告组件

bash 复制代码
#全局安装newman
npm install -g newman
bash 复制代码
#全局安装html报告组件
npm install -g newman-reporter-html

2.newman运行

newman使用流程:在已经装好环境的情况下,首先需要在postman上将请求组成的集合、所有用到的变量全部导出,在命令行中执行命令

运行测试即可。

首先我先将需要通过newman运行的集合,整个导出来,如图:

然后在cmd中执行命令:

bash 复制代码
#			postman导出的脚本文件路径
newman run test.postman_collection.json

如图演示:只运行脚本,不生成报告等

newman还有很多参数:

bash 复制代码
#指定环境变量
-e
#指定全局变量
-g
#指定外部参数化文件
-d
#指定迭代次数
-n
#指定运行后报告的类型可以是:xml、json、html、htmlextra
-r
#生成报告并指定报告的存储位置,以下分别是,html、json、xml、htmlextra报告
--reporter-html-export test.html
--reporter-json-export test.json
--reporter-xml-export test.xml
--reporter-htmlextra-export test.html

例子:

首先我们要先把需要的环境变量 、全局变量、以及脚本导出来,如图



把需要的东西都准备好后,输入命令执行即可

bash 复制代码
newman run test.postman_collection.json -e mytest.postman_environment.json -g workspace.postman_globals.json -d test.csv -n 1 -r html --reporter-html-export test.html

如图:

相关推荐
赶路人儿9 小时前
postman并发测试某个接口
测试工具·postman
一直开心9 小时前
Qunit学习总结2
测试工具·qunit
一个幽默的程序员10 小时前
API测试工具:Swagger vs Postman 2025最新全面对比
测试工具·postman
互联网杂货铺13 小时前
软件测试之压力测试
自动化测试·软件测试·测试工具·jmeter·职场和发展·测试用例·压力测试
danbing22261 天前
postman传query一个数组类型的参数,并且数组里面只有一个值的时候
postman
伊一大数据&人工智能学习日志1 天前
selenium爬取苏宁易购平台某产品的评论
爬虫·python·selenium·测试工具·网络爬虫
测试19981 天前
接口测试工具:Postman
自动化测试·软件测试·python·测试工具·职场和发展·接口测试·postman
测试杂货铺1 天前
接口测试及常用接口测试工具(Postman/Jmeter)
自动化测试·软件测试·测试工具·jmeter·测试用例·接口测试·postman