原文翻译
https://learning.postman.com/docs/tests-and-scripts/write-scripts/test-scripts/
Write scripts to test API response data in Postman
在Postman写脚本测试API接口的响应
You can use post-response scripts in Postman to run JavaScript after a request runs. By including code in the Scripts > Post-response tab for a request, collection, or folder, you can write and validate API tests. You can also use post-response scripts for debugging your tests.
在Postman中,你可以在请求运行后使用事后响应脚本来运行JavaScript。通过在请求、集合或文件夹的“Scripts > Post-response”选项卡中包括代码,您可以编写和验证API测试。您还可以使用响应后脚本来调试测试
Testing in Postman
Postman测试
Some of the most common approaches to API testing are contract testing, unit testing, end-to-end testing, and load testing. Tests confirm that your API is working as expected, that integrations between services function reliably, and that any changes haven’t broken existing functionality.
API测试的一些最常见的方法是契约测试、单元测试、端到端测试和负载测试。测试确认您的API按预期工作,服务之间的集成功能可靠,并且任何更改都没有破坏现有功能。
You can write tests for your Postman API requests in JavaScript in the Post-response tab. You can also use test code to aid the debugging process when something goes wrong with your API project. For example, you might write a test to validate your API’s error handling by sending a request with incomplete data or wrong parameters.
您可以在"Post-response"选项卡中用JavaScript为Postman API请求编写测试。当API项目出现问题时,您还可以使用测试代码来帮助调试过程。例如,您可以编写一个测试来验证API的错误处理,方法是发送具有不完整数据或错误参数的请求。
单词翻译
post-response
事后响应
scripts
脚本
including
包括...在内
code
代码
post
快速邮递
common approaches
常见 方法
contract
契约、合同
integrations
集成
function
功能
functionality
功能
validate
验证
tab
选项、标签
aid
帮助、援助
debugging
调试
process
进程、过程
project
项目
handling
处理
incomplete
不完整的
parameters
参数、决定因素、规范