Postman导出报告

一、下载node.js

导出测试报告我们需要用到一个工具叫做newman,它是node.js开发的一个插件,要使用他需要先下载node.js,安装包可以去官网下载,这里我分享一个

链接: https://pan.baidu.com/s/179yLzwTtLH3eihYs_yxrZA?pwd=7bqt

提取码: 7bqt

下载node-v安装即可,node.js会自动配置环境变量所以不需要我们手动配置,下载完成以后 win + r 输入cmd打开命令提示符,输入node -v来验证是否安装完成,显示如下就说明安装完成了

二、安装Newman

接下来安装Newman,我们在命令提示符中安装

Newman这个下载有点抽象,有时候下载连接不上资源,所以要切换国内镜像源,如果可以直接下载的就不用切换,这个容易抽风,有时候就算你挂了魔法也提示连接不上资源

复制代码
//如果npm install -g newman安装连接不上就先输入这条命令切换镜像源
npm config set registry https://registry.npmmirror.com
//然后输入这条命令安装
npm install -g newman

安装完成后,newman -v 来查看newman是否安装成功

显示版本号说明安装成功

三、使用Newman导出报告

如果想要指定报告导出位置,则需要安装npm install -g newman-reporter-html

依旧是命令提示符安装

Newman的具体参数参考如下:

|----------------|---------------------------------------------|-----------------------------------------|
| run | newman run 集合名/url地址 | 运行一个集合,url地址位集合文件导出的url |
| -e | -e 导出的环境变量json文件路径 | |
| -g | -g 导出的全局变量的文件路径 | |
| -d | -d 用户迭代的数据源文件路径 | 指定用于迭代的数据源文件路径 |
| -n | -n 迭代次数 | 指定迭代次数 |
| -r, --reporter | -r 测试报告类型 | 指定此次运行的报告类型,cli、xml、json、html、htmlextra |
| --reporter | --reporter-json-export 报告文件名称及存储路径 | 生成json格式的测试报告(不建议生成,数据过大) |
| --reporter | --reporter-xml-export xmlReport.xml | 生成xml格式的测试报告 |
| --reporter | --reporter-html-export htmlReport.html | 生成html格式的测试报告 |
| --reporter | --reporter-htmlextra-export htmlReport.html | 生成htmlextra格式的测试报告 |

有了Newman就能开始生成报告了,我们先使用postman导出一个.JSON文件

接下来我们在命令提示符中输入

复制代码
newman run  你保存的.json文件 -g 全局变量.json文件 -r html --reporter-html-export e:\test\report1.html

这样就生成一个标准的报告

最后的那个--reporter-html-export e:\test\report1.html是你要生成的HTLM测试报告的地址,起个名字叫做report1.html,这个是普通的的HTML报告,他其实还有个高级版的报告

加强版的报告我们需要安装:

npm install -g newman-reporter-htmlextra

注意跟上面的npm install -g newman-reporter-html不一样不要写错了
生成方式也很简单只要把html --reporter-html-export更改成

htmlextra --reporter-htmlextra-export

可以根据上面提供的各种参数来根据自己的需求添加

相关推荐
程序员与背包客_CoderZ2 小时前
Node.js异步编程——Callback回调函数实现
前端·javascript·node.js·web
傻小胖2 小时前
三种常见接口测试工具(Apipost、Apifox、Postman)
测试工具·postman
辛普森Mmmm5 小时前
Postman接口测试
测试工具·postman
程序员三藏6 小时前
软件测试之功能测试详解
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例
HWL56799 小时前
Express项目解决跨域问题
前端·后端·中间件·node.js·express
爱编程的小学究11 小时前
【node】如何把包发布到npm上
前端·npm·node.js
2501_9153738812 小时前
全栈项目实战:Vue3+Node.js开发博客系统
node.js
狂野小青年13 小时前
npm 报错 gyp verb `which` failed Error: not found: python2 解决方案
前端·npm·node.js
鲁鲁51713 小时前
Windows 环境下安装 Node 和 npm
前端·npm·node.js
Adorable老犀牛14 小时前
npm install 报错
npm·node.js