Postman + Newman + Jenkins 接口自动化

1. 本机没有安装node.js,先安装

1.1 去官网下载

地址1:https://nodejs.org/en/download/ ,我下载的是 【Windows 安装包(.msi)】
地址2:https://nodejs.org

图片.png

1.2 检测PATH环境变量是否配置了Node.js

点击开始 -- 运行 -- cmd -- 输入"path"

检测环境变量是否已配置node.js
1.3 检查Node.js版本

命令:node --version 或 node -v

检查Node.js版本.png

2. 安装Newman

2.1 全局安装

cmd中敲入:npm install -g newman

安装Newman.png
2.2 安装报告newman-reporter-html

cmd 输入:npm install -g newman-reporter-html
样式2:npm install -g newman-reporter-htmlextra

安装报告.png

3. 使用

3.1 从postman下载脚本到本机
下载测试用例脚本.png
3.2 下载环境变量
下载环境变量.png
3.3 本机调试报告样式

newman run D:\AutoPresent\0.Login.json -e D:\AutoPresent\1.Test_enVirables.json -r html --reporter-html-export Test1218.html
newman run D:\AutoPresent\0.Login.json -e D:\AutoPresent\1.Test_enVirables.json -r htmlextra --reporter-html-export Test1218.html

本机调试命令.png
运行完成后导出的目标文件夹已包含了该报告
3.4 去 jenkins 集成

新建一个构建,然后在构建的地方,配置 windows的批处理命令,点击立即构建,查看控制台输出,在导出的目标文件夹下同样会生成报告

cd /
cd C:\Users\Queenie\AppData\Roaming\npm
newman run D:\newman_qdd.postman_collection.json -e D:\qdd_bg_enviroment.postman_environment.json --reporters html --reporter-html-export D:\html001.html

4. 报告效果

简单的样式效果.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容