随笔 - 40  文章 - 0  评论 - 0  阅读 - 13086

postman断言使用

Postman使用

1)基础篇

1.常规断言-断言tests

Tests 为执行断言后的测试结果

tests["Body matches string"] = responseBody.has("2018-05-15");

测试返回的状态码

tests["Status code is 200"] = responseCode.code === 200;

测试返回的状态信息

测试响应时间是否低于200ms

检查响应body中等于指定string

tests["Body is correct"] = responseBody === "response_body_string";

检查Content-Type 是否包含在header返回(大小写不敏感)

tests["Content-Type is present"] = postman.getResponseHeader("Content-Type");

检查成功post请求,或可以接着往下走

tests["Successful POST request"] = responseCode.code === 201 || responseCode.code === 202;

posted on   韩文星  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示