> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards.md).

# 测试标准

本节描述了在 Decentraland 各项目的不同服务和 UI 中进行测试的方式。

本文档中的关键词“必须”（MUST）、“禁止”（MUST NOT）、“要求”（REQUIRED）、“应当”（SHALL）、“不应”（SHALL NOT）、“应该”（SHOULD）、“不应该”（SHOULD NOT）、“推荐”（RECOMMENDED）、“可以”（MAY）和“可选”（OPTIONAL）应按……中的描述进行解释。 [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119).

## 概览

测试是我们开发流程中的关键部分。我们在所有项目中都保持高标准的测试覆盖率和质量。本档提供了以下方面的全面指南：

* [**编写测试**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md) - 编写可维护、清晰测试的通用原则和模式
* [**测试 UI**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-uis.md) - 测试 React 组件、Redux saga、reducer、selector 和 action creator
* [**测试服务（Well-Known-Component）**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-services-wkc.md) - 测试基于 well-known-component 架构构建的模块化服务
* [**测试服务（已弃用）**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-services-deprecated.md) - 测试服务的旧版方法（供参考）
* [**测试端到端**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-e2e.md) - 使用 Cypress 进行端到端测试（进行中）

## 测试理念

我们的测试方法强调：

* **清晰性** - 测试应当自解释且易于理解
* **可维护性** - 当需求变化时，测试应当易于更新
* **隔离性** - 每个测试都应独立运行，不影响其他测试
* **覆盖率** - 应测试所有关键路径和边界情况
* **值** - 测试应能让人确信代码按预期工作

## 快速链接

* [如何使用……来描述上下文 `describe`](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#describing-and-building-context)
* [如何使用……来编写期望 `it`](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#describing-expectations-and-executing-code)
* [测试什么以及何时测试](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#what-to-test)
* [何时以及如何进行 mock](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#when-to-mock)

## 相关标准

* [依赖管理](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/dependency-management.md) - 管理 npm 依赖和 peerDependencies
* [UI 标准](https://github.com/decentraland/docs/blob/main/contributor/contributor-guides/ui-standards/README.md) - Redux 和 RTK Query 模式
* [API 文档](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/api-documentation.md) - OpenAPI 文档标准


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
