> 技术文档 > postman+newman+allure+jenkins_postman+allure+jenkins

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即可

 环境配置一栏

软件 版本 windows下查看版本的命令 说明 postman 11.47.3 settings的About下面 编写和导出接口测试脚本 nodejs 18.20.8 node -v 命令行主要使用它的npm指令下载newman和

newman-reporter-html,newman-reporter-allure

newman 6.2.1 newman -v 命令行使用newman指令 newman-reporter-html 1.0.5 npm list newman-reporter-html -g 使用newman指令根据postman脚本生成html测试报告 newman-reporter-allure 3.2.1 npm list newman-reporter-allure -g  使用newman指令根据postman脚本生成allure的测试报告 allure(allure-commandline) 2.32.0 allure --version 使用allure serve 指令将当前文件夹下allure测试报告生成html版本 jdk 17.0.11 java -version 因为allure是基于java开发的,jenkins运行也是需要的,所以需要安装 jenkins 2.479.1 java -jar \"jenkins .war\" --version jenkins通过一些列配置,借助allure也可以生成上图的html可视化报告

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的项目以及配置

 

 以上仅为测试使用,可能有不足之处,请多多指教。