一、安装 newman
NodeJS 提供了一个 newman 模块工具,它可以帮助我们在非 UI 模式下运行测试用例。接下来我们安装一下 newman 这个工具。
1.安装 node.js
下载地址:https://nodejs.org/en/download/package-manager
2.安装 newman
打开 cmd 命令行窗口,输入命令安装npm install newman --global。或者用命令cnpm install newman --global
二、导出postman的测试脚本
把脚本导出,放到node_modules 目录下

三、运行测试脚本
newman 安装完成后,接下来我们准备运行测试脚本。但在运行之前需要把测试脚本文件和测试数据 csv 文件拷贝到 node_modules 目录下,保证 newman 与测试脚本文件和测试数据文件在同一个目录下。
接着打开 cmd 命令行窗口,进入 node_modules 目录。
1

2.

其中,sfAPIIIII.postman_collection.json是我的测试脚本,-d 代表测试数据,-r 代表测试报告类型,html是生成测试报告(报告类型有四种html、cli、json、junit看自己喜好用什么),报告会生成在newman目录下。
四、查看测试报告
恭喜你测试报告已然生成,惊不惊喜!

友情链接:Postman项目实战 - 简书
网友评论