[CLAUDE] Docs: chốt rule timing unit test (1 bảng 5-row compact)

- rules.md §7: thêm section "Khi nào viết test — timing rule"
  4 case (feature mới/bug fix/critical algorithm/spec change) + 1 skip list
- CLAUDE.md root: 1 dòng quick reference timing rule
- User confirm pattern Phase 1-8 (test-after pragmatic) là default cho solo dev
- Test-before BẮT BUỘC chỉ khi: bug fix (regression test) + critical algorithm
- Spec change KHÔNG ngừng test — update test cũ + code, commit chung

Commit MD-only → CI skip (path filter gotcha #41), 0s deploy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-04-30 00:40:24 +07:00
parent b874743081
commit d2298fa614
2 changed files with 11 additions and 1 deletions

View File

@ -291,6 +291,16 @@ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
❌ E2E (Playwright) — KHÔNG làm (brittle cho solo dev)
```
### Khi nào viết test — timing rule
| Tình huống | Quy tắc |
|---|---|
| **Feature mới** | **Test-after**: UAT 2-3 lần ổn → viết test (≤1 commit theo sau). Pattern Phase 1-8 đã làm. |
| **Bug fix** | **Test-before BẮT BUỘC**: reproduce bug bằng test failing → fix → green. "1 bug = 1 regression test before merge". |
| **Critical algorithm** (code generator atomic, workflow guard, financial calc, security check) | **Test-before merge** — edge case nhiều, race condition đắt nếu break prod. |
| **Spec change** (không phải bug) | Update test cũ + code, commit chung. **KHÔNG xóa, KHÔNG skip** test cũ. Coverage chỉ tăng. |
| **Skip test** | DTO mapping, CRUD master đơn giản, FE component snapshot, wrapper passthrough, migration backfill idempotent. |
### Quy tắc bổ sung mỗi feature mới
- **Domain entity / enum** → 0 test (compile check đủ)