Coding unit test
Skill morning-start/agent-skills/process/project-management/coding-unit-test
AI 编程助手的专业技能库,涵盖 30+ 技能,按 6 类组织
npx -y skills add morning-start/agent-skills --skill coding-unit-testAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
编码与单元测试工具。指导前后端并行开发、代码编写规范、单元测试撰写。适用于研发执行阶段的核心生产环节。
SKILL.md
2.5 KB, as published. Nobody here has run it
编码与单元测试
最核心的"生产"环节。
核心流程
前端开发 → 后端开发 → 前后端联调 → 单元测试
1. 前端开发规范
代码规范
| 规范项 | 说明 |
|---|---|
| 命名规范 | 变量/函数:camelCase;组件:PascalCase |
| 代码格式 | 使用Prettier/ESLint统一格式 |
| 注释规范 | 复杂逻辑必须添加注释 |
| Git提交 | 提交信息遵循conventional commits |
组件开发 checklist
- 组件职责单一
- Props类型定义完整
- 处理好边界条件(空数据、加载中、错误状态)
- 避免硬编码
2. 后端开发规范
分层架构
Controller → Service → Repository
↓ ↓ ↓
接收请求 业务逻辑 数据库操作
代码规范
| 规范项 | 说明 |
|---|---|
| 命名规范 | 类名:PascalCase;方法:camelCase |
| 异常处理 | 统一异常捕获,分类处理 |
| 日志记录 | 关键操作记录日志 |
| 事务管理 | 多表操作使用事务 |
安全checklist
- 参数校验
- SQL注入防护
- 权限校验
- 敏感数据脱敏
3. 单元测试
测试金字塔
/\
/ \ E2E测试 (少)
/----\ 集成测试 (中)
/ \ 单元测试 (多)
/--------\
单元测试结构(AAA模式)
describe('计算总价', () => {
it('应正确计算单个商品总价', () => {
// Arrange - 准备测试数据
const items = [{ price: 10, quantity: 2 }];
// Act - 执行被测方法
const total = calculateTotal(items);
// Assert - 验证结果
expect(total).toBe(20);
});
});
测试覆盖要求
| 场景 | 最低覆盖率 |
|---|---|
| 核心业务逻辑 | 80%+ |
| 工具函数 | 90%+ |
| 分支处理 | 覆盖所有if/else |
4. 每日站会
3问模板
昨天:完成了xxx任务
今天:计划做xxx任务
阻塞:遇到yyy问题,需要zzz支持
风险升级机制
风险识别 → 记录到风险清单 → 及时上报 → 制定应对方案
使用场景
- 正式进入编码阶段
- 代码审查(Code Review)
- 每日站会同步进度
关键产出
- 源代码(符合规范)
- 单元测试报告
- 每日站会纪要