为什么要在命令行中运行

  可以在无UI界面的服务器上运行

  可以在持续集成系统上运行

从命令行运行postman脚本

 

 

运行准备

  导出collection

  安装nodejs和npm(或cnpm)

  安装Newman

运行及生成测试报告支持4中格式:

  ①CLIreporter

  ②JSON reporter

  ③HTML reporter

  ④JUnit reporter

 

nodejs下载地址: https://nodejs.org/en/ 

 

从命令行运行postman脚本

安装Newman:

从命令行运行postman脚本

 导出Collection v2 文件

从命令行运行postman脚本

 

从命令行运行postman脚本

导出后的其实是一个json文件如下图:

从命令行运行postman脚本

 

先cd到 测试脚本所在的目录,输入 newman run 测试脚本.json -d 测试数据.json  -r 生成测试报告的格式名小写例如html 可以同时生成多种中间用英文,隔开

 从命令行运行postman脚本

 

运行结果如下图:

 

从命令行运行postman脚本

生成HTML格式报告:

从命令行运行postman脚本

 

 从命令行运行postman脚本

 

相关文章: