postman+newman+allure+jenkins_postman+allure+jenkins
概要
由于postman可以制作接口测试的脚本,但是不具备完整的测试报告导出功能,
newman可以在cmd界面运行postman导出的测试报告脚本
newman run hc1.json
newman也可以在cmd界面将运行的结果显示为html页面
newman run hc1.json --reporters html --reporter-html-export index.html
allure测试报告结果是一些json文件,需要借助allure工具才可以生成html可视化报告
newman run hc1.json --reporters allure --reporter-allure-export allure-results
allure serve
此时交给jenkins去做接口自动化测试,jenkins通过一些列配置,借助allure也可以生成上图的html可视化报告,如图点击allure report即可
环境配置一栏
newman-reporter-html,newman-reporter-allure
postman编写接口信息和设置测试的脚本
接口相关信息:
方式:POST URL:http://shop-xo.hctestedu.com/index.php?application=app&s=api/user/loginRequest Body: {\"accounts\": \"请输入你的用户名\",\"pwd\": \"请输入你的密码\",\"type\": \"username\"} Response Body:{ \"msg\": \"登录成功\", \"code\": 0, \"data\": { \"token\": \"返回给你的token\" }}
postman的测试脚本编写:
接口整体测试:
运行的接口校验结果:
jenkins中运行接口测试的脚本
1.jenkins插件中安装allure 2.32.0的插件
2.设置全局变量JDK17
3.设置全局变量allure 2.32.0
4.找到jenkins中的主目录,
配置config.xml中的以下代码更改为自己项目所在的目录
5.创建jenkins的项目以及配置
以上仅为测试使用,可能有不足之处,请多多指教。