Files
2026-09-30 11:11:54 +08:00

23 lines
1.2 KiB
Plaintext
Raw Permalink 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.
---
description: 测试要求(后端 Pest/PHPUnit、Python pytest)
globs: backend/tests/**,py-service/tests/**
alwaysApply: false
---
# 测试要求
详见 `docs/14-testing.md`。核心业务没有测试不继续堆功能。
## 必测
Tenant Isolation、RBAC、Inventory、Concurrent Inventory、Inbound、Outbound、Allocation、Picking、Stocktake、Order Status、Queue、API Authorization。
## 关键用例
- **库存并发**:库存 10,两个请求同时扣 8 → 只能成功一个,不出现 `available_qty = -6`。并发测试需使用真实 MySQL(不用 SQLite),多进程 / 多连接触发。
- **租户隔离**:租户 A 通过列表、详情、业务编码、批量操作都无法访问租户 B 数据。
- **状态机**:合法转换成功并记录日志;非法转换(如 `draft → shipped`)被拒绝。
- **库存流水**:每次余额变化都有流水,流水累计与余额一致。
- **授权**:无权限用户调用接口返回失败格式与正确状态码。
## 约定
- Feature 测试覆盖 API(含返回格式),Unit 测试覆盖 Domain 规则与状态机。
- 使用 Factory 构造数据,Factory 默认带 `tenant_code`。