postman测试结果生成测试报告
背景
在postman完成自动化接口测试脚本的编写,并且测试脚本正确的情况下,为了执行脚本能够生成测试报告用于分析的情况下,需要生成测试报告。
软件安装
默认已经安装了node.js(网上有很多如何安装node.js的资料,这里不对如何安装软件进行讲解)
使用下面命令安装依赖
npm install --global --production windows-build-tools
我在安装过程中出现了下提示,表示打开cmd时,需要以管理员身份运行。
Please restart this script from an administrative PowerShell!
安装错误
依赖安装成功

使用下面的命令安装newman,完成newman安装
npm install -g newman
newman安装成功
将脚本导出为JSON
这里为了方便,我提前准备了一份接口测试的脚本,使用postman可以直接导入。导入链接为:
将Collection导出,选择“Collection v2”。v1和v2。Collection v1和v2都作为JSON文件下载; v2是更多功能和最常用的选择。了解v1与v2更多信息。

我将JSON文件导出到了路径“I:\Users\dengdai68\Downloads\tester\http req.postman_collection.json”
生成测试报告
在cmd中执行下面语句,生成测试报告。测试报告生成路径为“D:/req_result/result.html”。
newman run "I:\Users\dengdai68\Downloads\tester\http req.postman_collection.json" --reporters html --reporter-html-export D:/req_result/result.html
生成result.html结果如下

或者使用我提供的Collection链接直接生成报告
newman run "https://www.getpostman.com/collections/319909560cdd7cbc407c" --reporters html --reporter-html-export D:/req_result/net_link_result.html --timeout-request 5000
上一篇 | postman测试结果生成测试报告 | 下一篇 |
---|