【接口测试】8_Postman _Postman测试报告

文章目录

一、创建用例集

1.1 创建 collections

1.2 创建用例集的子目录和请求

二、批量执行测试用例(重点)

批量执行测试用例:就是要执行的一个个用例集。

导出用例集之前:确认用例集中的每一个用例执行都无误,之后才可以批量执行。

三、管理用例集

3.1 用例集-导出

3.2 用例集-导入

四、导出环境变量文件

http请求中,使用到环境变量,除了要导出用例集以外,还要导出环境变量文件。

五、newman生成测试报告

使用newman命令,运行导出的测试集脚本,打开cmd输入。

5.1 命令语法

shell 复制代码
# 完整命令
newman run 用例集文件.json -e 环境变量文件.json -d 数据文件.csv/.json -r htmlextra --reporter-htmlextra-export 测试报告名.html

newman run 用例集文件.json -e 环境变量文件.json -d 数据文件.csv/.json -r html --reporter-html-export 测试报告名.html

newman 生成报告的命令【必须】
run 用例集文件.json:表示要执行的postman脚本,即导出的测试集数据。【必须】
-e source:用来指定环境变量文件的路径。【可选】
-d source:用来指定测试数据文件的路径。【可选】
-r htmlextra --reporter-htmlextra-export  【固定写法】
如果 使用 htmlextra 报错。修改使用 html
-r html --reporter-html-export  【固定写法】

-r:可选,指定测试报告的类型,如果想生成对应的报告类型,需要添加这个参数,典型的有 HTML、JSON、cli,若不添加,默认为 cli。

5.2 步骤

  1. 执行测试用例集。(确认无误)
  2. 导出 Export 用例集。(得到 xxxx.json文件,数据文件 放在一起)
  3. 若有环境变量,导出环境变量文件。
  4. 在 终端 中 执行命令,生成测试报告
shell 复制代码
# 在 终端中,测试一下。所有内容打在终端中,不会生成报告。(xxxx.json--测试脚本文件)
newman run xxxx.json
# 完整的命令
newman run xxxx.json -e 环境变量文件 -d 外部数据文件 -r html --reporter-html-export 测试报告名.html


# 参考命令1 - 使用 htmlextra
newman run 生成测试报告.postman_collection.json -e 测试环境.postman_environment.json -r htmlextra --reporter-htmlextra-export 测试报告1.html

# 参考命令2 - 使用 html
newman run 生成测试报告.postman_collection.json -e 测试环境.postman_environment.json -r html --reporter-html-export 测试报告2.html

# 参数命令3 - 使用数据文件 生成测试报告
newman run 参数化-手机号运营商.postman_collection.json -d 手机号.csv -r htmlextra --reporter-htmlextra-export report2.html
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


# 示例:
newman run 批量执行测试用例.postman_collection.json -r html
newman run 批量执行测试用例.postman_collection.json -r html --reporter-html-export 我的第一个测试报告.html

#输出测试报告到C:\Users\ggk\Desktop\pp\指定路径
newman run "C:\Users\ggk\Desktop\pp\Ihrm.postman_collection.json" -r html --reporter-html-export C:\Users\ggk\Desktop\pp\report.html

# 如果添加 -r html 就报错!说明: newman-reporter-html 安装失败!
相关推荐
螺丝钉tina7 小时前
[Playwright] [02]常用命令与调试:Debug UI、Mode和 Trace Viewer
开发语言·javascript·测试工具·ui·自动化
梧桐1681 天前
14天、31个缺陷、28个测试脚本—用 Claude Code 完成第三方软件测试
人工智能·测试工具
mewowaBc2 天前
postman使用细则
测试工具·postman·偏差
光影6272 天前
Unittest单元测试基础速记
测试工具·单元测试·json·测试覆盖率
xie881018022 天前
正则里的点号不匹配换行:多行模式的开关
运维·服务器·测试工具
东舟技术4 天前
从人工目检到AI视觉:智能座舱瞬态故障的自动化捕获与溯源
功能测试·测试工具·自动化
小猿A4 天前
【2026最新】Apifox下载、配置、实战教程(附官网安装包)
测试工具
洋不写bug5 天前
HTTP(二):万字解析HTTP交互的请求、响应报文格式
网络协议·http·交互·postman·请求格式·响应格式·restful规范
泽众云测试5 天前
泽众软件与广州华南检验检测中心签约,PerformanceRunner性能测试工具助力第三方测评机构性能检测能力升级
软件测试·测试工具·性能测试
@zulnger5 天前
Charles抓包工具
测试工具