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

如图:

相关推荐
持续前进的奋斗鸭1 小时前
Postman测试学习(1)
学习·postman
代码的乐趣8 小时前
支持selenium的chrome driver更新到137.0.7151.68
chrome·selenium·测试工具
程序员三藏1 天前
如何使用Jmeter进行压力测试?
自动化测试·软件测试·python·测试工具·jmeter·测试用例·压力测试
编程乐学(Arfan开发工程师)1 天前
42、响应处理-【源码分析】-浏览器与PostMan内容协商完全适配
java·spring boot·后端·测试工具·lua·postman
集成显卡2 天前
PlayWright | 初识微软出品的 WEB 应用自动化测试框架
前端·chrome·测试工具·microsoft·自动化·edge浏览器
互联网杂货铺2 天前
完美搭建appium自动化环境
自动化测试·软件测试·python·测试工具·职场和发展·appium·测试用例
测试老哥2 天前
Jmeter如何进行多服务器远程测试?
自动化测试·软件测试·功能测试·测试工具·jmeter·测试用例·性能测试
鱼鱼说测试2 天前
postman基础
测试工具·postman
程序员杰哥2 天前
Postman常见问题及解决方法
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·postman