关于 Postman 介绍与使用

You,2 min read

关于 Postman 介绍与使用

官方文档 https://learning.postman.com/ (opens in a new tab)

Features

Mock API Request 模拟接口请求

创建即可 输入你的 api 名字、方法和入参即可 详见 (opens in a new tab)

比如我现在需要模拟 RPC 调用我的本地开发阶段的 Node 接口

http://localhost:8088/generate/user

传入

{
 id: '123',
 name: 'xiaoming'
}

可以直接在 VS Code 中启用调试 运行自己的 Node 服务

触发 本地 Service API 的调用

cMnxjt

Write a test 编写 API 测试用例

在接口的后面 Tests 中面板包含了这些即可进行测试 详见 (opens in a new tab)

TowAO9

Create Collection 创建集合

集合的主要作用就是收集相关的 API 模拟

比如:我现在负责电商项目的 API 自动化测试 那么我的集合名字就可以称为 Mall

新建 API 保存的时候会需要你选择需要保存的 Collection 详见 (opens in a new tab)

Mock Server 模拟服务

左侧 Sidebar 新建即可 [文档详见](https://learning.postman.com/docs/designing-and-developing-y (opens in a new tab) our-api/mocking-data/setting-up-mock/)

SkBCRL

完整流程如下

Step1 创建 Mock Collection & Save Example

SCR-20231113-rnzz

Step2 选择 Mock Collection 创建 Mock Servers

SCR-20231113-rqce

IWLrby

xYnH5u

Step3 Postman 或 Node Server 请求到 Mock Server

至此 你看一通过 Postman 直接 API Request 到 Mock Server 返回的值即为

此前定义的 Mock Java API 中你定义的对应示例 至于示例的详细匹配 详见 (opens in a new tab)

postman-mock-servers

2026 © Lizhenyui.