9、从命令行运行postman脚本及生成测试报告

本节建议直接看postman官网:https://www.npmjs.com/package/newman

环境准备:

  • 安装nodejs和npm     参考 https://www.runoob.com/nodejs/nodejs-install-setup.html
  • 导出collection
  • 安装newman    

第一步:导出collection,选择collection v2

第二步:安装newman,出现以下内容说明安装成功

 

第三步:使用命令行生成测试报告,前置条件,进入到v2ex.postman_collection.json目录

newman run v2ex.postman_collection.json -d test_data.json -r html,cli,json,junit //命令行

  

第四步:查看测试报告

方式一:在命令行查看测试报告:

方式二:查看html测试报告,当我们执行newman run v2ex.postman_collection.json -d test_data.json -r html,cli,json,junit 这条命令,会在v2ex.postman_collection.json同级目录生成一个newman文件,我们打开里面的html文件

猜你喜欢

转载自www.cnblogs.com/suim1218/p/8931212.html