# 单元测试自动生成

> 生成覆盖正常路径、边界与异常的聚焦单元测试。

**Kind:** skill · **Domain:** Engineering · **ID:** `unit-test-generator`

## 输入输出契约

| 输入 | 输出 |
| --- | --- |
| 函数源码、测试框架、现有测试规范 | 测试文件、用例清单、覆盖率说明 |

## 工作流程与操作说明


2. Understand the function contract and side effects.
4. List happy-path, boundary and failure cases.
6. Write isolated tests using the project's existing framework.
8. Mock external dependencies deterministically.
10. Verify all tests pass and note uncovered branches.



## 起手提示词

```text
为这个函数编写覆盖边界情况的单元测试。
```

## 常见问题

### 这是一项真实存在于 Clavue Bot 的能力吗？

是的。本页内容由产品内置目录生成，能力名称、输入输出与操作步骤都对应真实可用的场景、技能、MCP 工具或数字员工。

### 需要额外配置工具或连接器吗？

标注「开箱即用」的能力无需额外工具；标注「需连接工具」的能力会列出所需连接器，首次运行时按提示授权即可。

### 它会未经确认就发邮件或付款吗？

不会。发信、付款、提交表单等对外动作会停下来先请你确认，你同意后才会继续。

Canonical: https://ability.clavue.com/zh/skill/unit-test-generator/
