# Postman Tests

Postman Tests 中如何提取请求 Body 中的参数?
在 Postman 中,使用pm.request.body对象可以轻松提取请求 Body 中的参数。此外,你还可以将提取的参数存储在环境变量中,以便在其他请求中访问。

Postman Tests 中如何提取响应 Body 中的参数?
在 Postman 中,使用 JavaScript 编写测试脚本可提取响应 Body 中的参数。通过解析 JSON 格式的响应 Body,可以轻松提取所需参数,并可选择将其存储在环境变量中供其他请求使用。

Postman 的 Tests 是什么?怎么写?
Postman 的 Tests 是用于验证请求响应是否符合预期的自动执行脚本,使用 JavaScript 编写,并提供预定义的断言函数检查各个方面。Tests 可针对每个请求或在 Collection/Folder 级别共享编写。除了验证状态码,还可检查响应体、响应时间、响应头、字段值等。