教程
学习 API 测试
本教程从什么是 API 讲起,最后讲到负载测试和 CI 流水线。前七课不需要会编程。之后,一些示例会用到 JavaScript 或 Python,每个都足够短,可以直接复制运行。
课程中的每个请求都发往一个真实的 API:https://api.testingapis.com。 它接受写入,并且有专门以特定方式失败的端点,因此你可以练习那些在别处难以复现的问题。大多数示例都有一个“发送”按钮,可以直接在本页运行请求。前几课使用不需要账户的端点;后面的课程需要一个免费账户,登录后它们的“发送”按钮即可使用。
19 课3 个级别免费
入门
7 课什么是 API、HTTP 如何工作,以及如何发送请求并读懂返回的内容。
进阶
7 课正确地测试真实端点:CRUD、校验、身份验证、请求头,以及用代码编写的测试。
- 08端到端测试一个资源创建、读取、更新和删除,并检查每一步是否真的发生了。
- 09测试校验和错误错误的输入、缺失的字段、错误的类型,以及好的错误是什么样子。
- 10筛选、排序和分页那些直到第 3 页才有人注意到的列表端点 bug。
- 11Authentication and authorizationBasic auth, API keys, bearer tokens and JWTs, and the difference between 401 and 403.
- 12Headers, caching and cookiesContent negotiation, ETags, 304 responses and session cookies.
- 13Automating tests with codeTurning manual checks into tests with JavaScript or Python.
- 14Schemas and contract testingChecking the shape of a response, and using an OpenAPI document as the source of truth.
高级
5 课只在生产环境中出现的故障:超时、异步任务、安全漏洞和负载。
- 15Timeouts, retries and rate limitsFlaky servers, idempotency keys, 429 responses and how clients should behave.
- 16Async jobs, webhooks and streamsTesting work that finishes later, requests the server sends to you, and open connections.
- 17Security testing basicsBroken object access, auth bypasses, mass assignment and injection.
- 18Performance testingMeasuring latency, reading percentiles and running a small load test.
- 19Running tests in CITest data, flaky tests, pipelines and deciding what to test at all.