本文共 1771 字,大约阅读时间需要 5 分钟。
在执行接口测试脚本之前,需要选择合适的测试工具。以下是几点值得考虑:
接口测试脚本的执行流程通常包括以下步骤:
Postman工具结合Newman和Jenkins可以实现接口自动化测试。以下是常见流程:
安装Newman:
npm install -g newman。export PATH="/root/tools/node-v14.8.0-linux-x64/bin:$PATH"
npm install -g newman。执行Postman脚本:
newman run mycollection.json。newman run demo.postman_collection.json -r html。newman run demo.postman_collection.json -r htmlextra。报告参数:
-r参数指定报告格式,如-r html,junit,json,htmlextra。--reporter-html-export htmlReport.html,--reporter-htmlextra-export htmlExtraReport.html。新man环境变量:
npm config set registry https://registry.npm.taobao.org。脚本管理:
Jenkins配置:
newman run demo.postman_collection.json -r htmlextra --reporter-htmlextra-export ./report/htmlExtraReport.html。钉钉通知:
安全设置:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")DirectoryBrowserSupport.CSP属性。高级方法:
Newman其他用法:
newman run --env-file .env mycollection.json。newman run -- iterations 10。newman-reporter-htmlextra插件:
newman run --filter "status:pass".newman run --reporter-htmlextra-export "Custom Report Title.html"。钉钉通知高级用法:
转载地址:http://ytxfk.baihongyu.com/