作用
(1)将测试 URL 进行定义成变量的形式,固定域名或者参数
(2)将一些敏感的测试值定义为环境变量,比如密码,不暴露
添加设置按钮,进入当前环境变量列表页面
配置使用环境变量,右侧为快捷方法
newman:Collection操作的命令行
使用教程
安装方式
npm install -g newman
用newman最主要的原因是postman无法自动多次运行某个collection
newman运行mycollection.json 10次 命令:
newman run mycollection.json -n 10
如果有环境变量和全局变量的设置,也需要导出到本地,然后以文件的形式指定
-e, --environment [file|URL] Specify a Postman environment as a JSON [file]
-g, --globals [file] Specify a Postman globals file as JSON [file]
要提供不同的数据集,可以指定本地JSON或CSV文件;数据文件运行多次迭代时,每次迭代使用其中一组变量
-d, --data [file] Specify a data file to use either json or csv
命令行举例
newman run mycollection.json -d data.json
运行完之后,必然是结果报告的获取了,可以将所有测试和请求的结果使用JSON报告器和文件名将运行器输出保存到文件中,然后导入Postman进行进一步分析。
newman run mycollection.json --reporters cli,json --reporter-json-export outputfile.json