TemplateProject/test/index.md
2026-05-21 20:32:32 +08:00

19 lines
800 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# test — 测试代码
本目录存放项目的全部测试代码。测试代码的组织结构应**镜像** `src/` 的结构,便于定位。
## 目录说明
| 子目录 | 用途 | 特点 |
|--------|------|------|
| `unit/` | 单元测试 | 测试最小单元(函数、方法),不依赖外部系统 |
| `integration/` | 集成测试 | 测试模块间交互或与外部系统数据库、API的集成 |
| `e2e/` | 端到端测试 | 模拟用户行为,从入口到出口的完整链路 |
## 测试原则
1. **先写测试,再写代码**(推荐 TDD
2. 每个 bug 修复都应伴随对应的回归测试
3. 测试用例命名应清晰描述测试场景:`<被测方法>_<场景>_<预期结果>`
4. 保持测试独立:单个测试不应依赖其他测试的运行顺序