Postman+Newman

参考文章:

postman+newman+jenkins持续集成-CSDN博客

【精选】Newman命令运行脚本生成postman的Html报告_newman离线安装包_测试+开发小白的博客-CSDN博客

Newman官方使用文档:Customize a collection run using Newman command options | Postman Learning Center

postman编写好接口之后,导出为json文件,并同步将环境变量以及全局变量导出

安装node.js以及Newman:

node.js官方下载地址: http://nodejs.cn/download/   (安装完成后需要配置环境变量)

Newman安装命令:npm install -g newman

安装完成后可以在cmd中执行node -v 和 newman -v查看是否安装成功

安装完成后在命令行执行Newman执行命令即可(完整命令):

newman run D:\PostmanRunner\Test\AIpicture\Test.postman_collection.json -e D:\PostmanRunner\environment\Huohua.postman_environment.json -g D:\PostmanRunner\globals\MyWorkspace.postman_globals.json -n 3 -r  html  --reporter-html-export D:\PostmanRunner\report\test_result.html

Newman 常用参数:

run,执行脚本的路径

  • newman run D:\PostmanRunner\Test\AIpicture\Test.postman_collection.json

-e , --environment 使用环境变量文件或url

使用时, 首先在环境变量中通过导出功能将环境变量导出, 然后用如下命令引用.

  • newman run D:\PostmanRunner\Test\AIpicture\Test.postman_collection.json -e D:\PostmanRunner\environment\Huohua.postman_environment.json

-g,  --global 使用全局变量文件或URL

类似-e的使用, 在使用前, 先导出全局变量文件, 再通过-g 指定文件使用

-d , --iteration-data 指定使用的数据驱动文件

  • newman run D:\PostmanRunner\Test\AIpicture\Test.postman_collection.json -g D:\PostmanRunner\globals\MyWorkspace.postman_globals.json

-n 指定测试集循环次数iterations

  • newman run D:\PostmanRunner\Test\AIpicture\Test.postman_collection.json  -n 3

newman -r     # newman测试报告

newman提供的测试报告中, 常用的包括cli, json和html 三种格式,可以通过-r 或者 -reporter 命令指定所用格式。

cli 格式为在cmd客户端呈现的报告模板, newman默认使用该格式

json格式可以导出json格式的报告,html格式可以到处html格式的报告

通过-r 进行设置,并加上 --reporter-报告格式-export 参数指定报告生成的路径

  • 同时使用cli,json两种格式: 通过-json 设置导出报告格式.
  • newman run D:\PostmanRunner\Test\AIpicture\Test.postman_collection.json -e D:\PostmanRunner\environment\Huohua.postman_environment.json -g D:\PostmanRunner\globals\MyWorkspace.postman_globals.json -n 3 -r json,cli  --reporter-json-export D:\PostmanRunner\report\test_result.json

html格式可以导出html格式的报告, 通过 -r html进行设置, 并加上 --reporter-html-export参数指定报告生成的路径.

先安装html报告模板:

npm install -g newman -reporter -html

  • newman run D:\PostmanRunner\Test\AIpicture\Test.postman_collection.json -e D:\PostmanRunner\environment\Huohua.postman_environment.json -g D:\PostmanRunner\globals\MyWorkspace.postman_globals.json -n 3 -r  html  --reporter-html-export D:\PostmanRunner\report\test_result.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值