> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJhMmEyOGZjOC01YjlhLTRjMzItYWQyNy05YTQ2OTQ1MmIyYTQiLCJleHAiOjE3NzgzNzI1ODAsImlhdCI6MTc3ODM3MjI4MH0.UG8dpBTZaXRB3Jh07bLV-KgZkfcngiYttuWlh5tnjVU
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 测试

> Fern 自动为 SDK 生成单元测试和模拟服务器测试，确保发布前的质量

Fern 通过生成的测试和手写的测试为你的 SDK 提供全面的测试。

## 生成的测试

<Warning title="专业版和企业版功能">
  此功能仅适用于[专业版和企业版计划](https://buildwithfern.com/pricing)。如需开始使用，请联系 [support@buildwithfern.com](mailto:support@buildwithfern.com)。
</Warning>

Fern 自动生成在 SDK 发布前必须通过的测试。Fern 在每个 SDK 仓库中生成一个 GitHub 工作流，在每次拉取请求、提交和发布时运行单元测试和任何启用的模拟服务器测试。

### 单元测试

Fern 为所有 SDK 语言生成单元测试。它们在不进行网络调用的情况下单独验证各个方法。

### 模拟服务器测试

模拟服务器（线路）测试针对从你的 API 定义生成的模拟服务器运行你的 SDK。它们验证 SDK 按预期发送 HTTP 请求和接收 HTTP 响应。这些测试为服务中的所有端点生成。

模拟服务器测试适用于 TypeScript、Python、Go、Java、C#、PHP、Swift、Rust 和 Ruby。在你的 `generators.yml` 中配置模拟服务器测试：

| 语言         | 配置                                                                                                     | 默认值   |
| ---------- | ------------------------------------------------------------------------------------------------------ | ----- |
| TypeScript | [`generateWireTests`](/learn/sdks/generators/typescript/configuration#generatewiretests)               | true  |
| Python     | [`enable_wire_tests`](/learn/sdks/generators/python/configuration#enable_wire_tests)                   | false |
| Go         | [`enableWireTests`](/learn/sdks/generators/go/configuration#enablewiretests)                           | true  |
| Java       | [`enable-wire-tests`](/learn/sdks/generators/java/configuration#enable-wire-tests)                     | false |
| .NET/C#    | [`generate-mock-server-tests`](/learn/sdks/generators/csharp/configuration#generate-mock-server-tests) | true  |
| PHP        | [`enable-wire-tests`](/learn/sdks/generators/php/configuration#enable-wire-tests)                      | false |
| Swift      | [`enableWireTests`](/learn/sdks/generators/swift/configuration#enablewiretests)                        | true  |
| Rust       | [`enableWireTests`](/learn/sdks/generators/rust/configuration#enablewiretests)                         | false |
| Ruby       | [`enableWireTests`](/learn/sdks/generators/ruby/configuration#enablewiretests)                         | false |

## 集成测试

<Warning title="企业功能">
  此功能仅适用于[企业计划](https://buildwithfern.com/pricing)。如需开始使用，请联系 [support@buildwithfern.com](mailto:support@buildwithfern.com)。
</Warning>

手写的集成测试针对你的真实 API 服务器运行，使用实时数据测试端到端功能。

## 添加额外测试

你可以直接向你的 SDK 仓库添加自定义测试。在你的 `.fernignore` 文件中包含测试文件，以防止在重新生成期间被覆盖。