newman工具的运用

 

是postman测试集合运行的插件工具,运行的对象是测试集合。

1、安装

安装nodejs,是newman的基础环境。

cmd--->npm -v

安装newman工具:

cmd ---> npm install -g newman@5.2.4

cmd -->newman -v

如果安装过程很慢,我们更新为国内淘宝的服务器:

npm config set registry http://registry.npm.taobao.org

2、newman的使用

第一步:导出测试集合、导出环境变量

新建collection集合,创建request,并调试通过,选中集合,选中export-->v2,点击导出。

导出environment环境,导出环境的json文件。

导出全局globals环境:

第二步:运行测试集合文件

cmd-->newman run 测试集合文件的全路径

newman run e:\aaa.collection.json

newman run e:\aaa.collection.json -e e:\envirement.json -g e:\globals.json

3、newman的常见参数

-e: 后面是指定environment环境文件全路径的参数

newman run e:\aaa.collection.json -e e:\envirement.json

-g:后面是指定globals环境文件全路径的参数

newman run e:\aaa.collection.json -e e:\envirement.json -g e:\globals.json

-n:后面跟一个数字,表示测试集合执行的迭代次数(就是循环执行的次数)

newman run e:\aaa.collection.json -e e:\envirement.json -n 2

-d: 后面跟的是参数化文件,json、csv文件数据

newman run e:\aaa.collection.json -e e:\environment.json -d e:\postmanCsv.csv

newman run e:\aaa.collection.json -e e:\environment.json -d e:\postmanJson.json

4、newman导出的报告类型

cli格式报告:就是cmd下运行生成的文件。

newman run e:\aaa.collection.json -e e:\environment.json -d e:\postmanJson.json > e:\result.txt

json格式的报告:postman的runner运行器中执行也会输出json格式报告。

newman run e:\aaa.collection.json -e e:\environment.json -d e:\postmanJson.json -r json --reporter-json-export e:\result.json

newman run e:\aaa.collection.json -e e:\environment.json -d e:\postmanJson.json -r json --reporter-json-export e:\data\result0325.json

html格式的可视化报告:

newman run e:\aaa.collection.json -e e:\environment.json -d e:\postmanJson.json -r html --reporter-html-export e:\data\result0325.html

5、打包批处理命令

为什么做批处理?安装Jenkins,使用jenkins来部署运行run.bat文件。

实现无人执行的运行脚本。

步骤1:新建一个txt文件,重名为run.bat文件,使用notepad++打开。

步骤2:将上面的newman命令,复制到改文件中,转码为utf-8

步骤3:双击run.bat文件。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值