欧洲网站设计,网站建设与运营课程,企业品牌策划与设计,公司网站建设费属于宣传费吗Postman之newman 1.基础环境node安装1.1.配置环境变量1.2.安装newman和html报告组件 2.newman运行 newman可以理解为#xff0c;没有命令行的postman#xff0c;把写好的测试脚本直接在命令行中运行#xff0c;newman依赖于node环境#xff0c;因此#xff0c;需要先安装好… Postman之newman 1.基础环境node安装1.1.配置环境变量1.2.安装newman和html报告组件 2.newman运行 newman可以理解为没有命令行的postman把写好的测试脚本直接在命令行中运行newman依赖于node环境因此需要先安装好node再安装newman 1.基础环境node安装
首先通过官网下载node
也可以通过网盘分享的文件下载node-v22.11.0-x64.msi 链接: https://pan.baidu.com/s/1TbNMD79NbgcTpPjsEi7jbQ?pwdb6ke 提取码: b6ke –来自百度网盘超级会员v2的分享 windows下载后双击文件运行一直下一步傻瓜式安装即可 如图则表示安装成功 1.1.配置环境变量 1.在开始栏中搜索环境变量点击进入即可 2.双击path新建环境变量输入node的安装路径 在cmd命令行中输入 #查看node版本
node -v
#查看npm版本
npm -v
#切换为淘宝镜像官网镜像下载速度很慢
npm config set registry https://registry.npmmirror.com/如图即可 1.2.安装newman和html报告组件
#全局安装newman
npm install -g newman#全局安装html报告组件
npm install -g newman-reporter-html2.newman运行
newman使用流程在已经装好环境的情况下首先需要在postman上将请求组成的集合、所有用到的变量全部导出在命令行中执行命令 运行测试即可。
首先我先将需要通过newman运行的集合整个导出来如图 然后在cmd中执行命令
# postman导出的脚本文件路径
newman run test.postman_collection.json如图演示只运行脚本不生成报告等 newman还有很多参数
#指定环境变量
-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例子 首先我们要先把需要的环境变量 、全局变量、以及脚本导出来如图
把需要的东西都准备好后输入命令执行即可
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如图