当前位置:网站首页>Postman核心功能解析 —— 参数化和测试报告
Postman核心功能解析 —— 参数化和测试报告
2022-07-05 18:35:00 【小码哥说测试】
1. 参数化处理
参数化:针对于某一个接口,有大量的的测试数据需要批量验证,一个一个的更改请求参数太耗时耗力,使用参数化批量处理数据会比较高效,常规通过文档参数化实现。
创建文件 格式CSV
文件内第一行信息 需要和参数变量匹配
批量执行
参数化断言
添加断言数据
// 设置变量assert
assert = pm.variables.get("assert");
// 断 言 message 字 段 值 为 success
pm.test("message字段值为success", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.message).to.eql(assert);
});
2. Postman生成测试报告
Postman使用runner
运行时,生成的报告只能在Postman内部查看,并不是很方便。所以可以生成一个HTML
报告,通过浏览器打开即可
Postman需要生成HTML
报告需要使用newman
,借助newman工具生成。
2.1安装newman
newman是使用node.js
开发,专门为postman做的生成测试报告的工具插件。我们需要安装node.js、newman、newman插件:newman-reporter-html
下载node.js:https://nodejs.org/en/ 建议安装15或者16版本
npm install -g cnpm --
registry=https://registry.npm.taobao.org安装newman:打开cmd,输入npm install -g newman
安装
newman-reporter-html
打开cmd,输入npm install -g newman-reporter-html
2.2newman命令运行用例
newman run 用例集.json -e 环境文件.json -d 数据文件.json -r html --repoter-html-export report.html
newman run 用例集.json
运行用例集的意思
-e 环境文件.json 指定运行的环境
-d 数据文件.json 指定运行的数据
-r html 生成html报告
--reporter-html-export report.html 指定html报告名称是report.html
执行前需要导出脚本/数据文件/环境文件例如:
newman run token.postman_collection.json -d logindata.txt -e pinter项目.postman_environment.json -n 3 -r html --reporter-html-export .\
执行后目录生成报告文件
最后感谢每一个认真阅读我文章的人,看着粉丝一路的上涨和关注,礼尚往来总是要有的,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走
这些资料,对于从事【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴我走过了最艰难的路程,希望也能帮助到你!凡事要趁早,特别是技术行业,一定要提升技术功底。希望对大家有所帮助…….
边栏推荐
- Use JMeter to record scripts and debug
- lombok @Builder注解
- EMQX 5.0 正式发布:单集群支持 1 亿 MQTT 连接
- How to write good code defensive programming
- Summary of six points of MySQL optimization
- Cronab log: how to record the output of my cron script
- @Extension, @spi annotation principle
- MySQL数据库索引教程(超详细)
- websocket 工具的使用
- 基于can总线的A2L文件解析(3)
猜你喜欢
案例分享|金融业数据运营运维一体化建设
Overview of video self supervised learning
LeetCode 6109. 知道秘密的人数
@Extension、@SPI注解原理
Isprs2020/ cloud detection: transferring deep learning models for cloud detection between landsat-8 and proba-v
解决 contents have differences only in line separators
进程间通信(IPC):共享内存
尚硅谷尚优选项目教程发布
2022 Alibaba Android advanced interview questions sharing, 2022 Alibaba hand Taobao Android interview questions
Copy the linked list with random pointer in the "Li Kou brush question plan"
随机推荐
Isprs2020/ cloud detection: transferring deep learning models for cloud detection between landsat-8 and proba-v
什么是文本挖掘 ?「建议收藏」
Electron installation problems
图扑软件数字孪生智慧风电系统
技术分享 | 接口测试价值与体系
Personal understanding of convolutional neural network
Thoroughly understand why network i/o is blocked?
Emqx 5.0 officially released: a single cluster supports 100million mqtt connections
7-2 keep the linked list in order
紧固件行业供应商绩效考核繁琐?选对工具才能轻松逆袭!
About statistical power
Take a look at semaphore, the current limiting tool provided by JUC
Record eval() and no in pytoch_ grad()
Low code practice of xtransfer, a cross-border payment platform: how to integrate with other medium-sized platforms is the core
Share: ZTE Yuanhang 30 Pro root unlock BL magick ZTE 7532n 8040n 9041n brush mask original brush package root method Download
sample_ What is the relationship between rate, sample and duration
sample_rate(采樣率),sample(采樣),duration(時長)是什麼關系
Interprocess communication (IPC): shared memory
集合处理的利器
C final review