---
title: 编写单元测试
product: Cloud Code
version: 3.1.0
latest_version: 3.1.0
status: This page documents version 3.1.0. The latest version is 3.1.0.
canonical: https://docs.unity.com/zh-cn/cloud-code/3.1.0/modules/how-to-guides/unit-testing
latest_url: https://docs.unity.com/zh-cn/cloud-code/3.1.0/modules/how-to-guides/unit-testing.md
last_updated: 2026-11-20
generated_at: 2026-12-03T02:38:04.813Z
locale: zh-cn
---

# 编写单元测试

> Write unit tests for your modules to identify and fix issues early in development.

对代码进行单元测试有助于在开发过程的早期识别和修复问题，确保代码按预期工作，并降低在模块中引入错误的风险。

| **主题**                                       | **描述**                                                    |
| -------------------------------------------- | --------------------------------------------------------- |
| [创建单元测试项目](./unit-testing-create-project.md) | 了解如何在 JetBrain Rider 或 Microsoft Visual Studio 中创建单元测试项目。 |
| [创建单元测试](./unit-testing-create.md)           | 参考示例了解如何为项目添加单元测试。                                        |

请参阅有关[创建第一个测试](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-nunit#creating-the-first-test)的 Microsoft 文档，详细了解使用 `NUnit` 进行单元测试。
