diff --git a/CLAUDE.md b/CLAUDE.md index f1dc46c..2b89819 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -89,7 +89,7 @@ tests/ dotnet test SolutionErp.slnx # chạy cả 2 test project ``` -**Quy tắc:** mỗi feature mới có guard logic / business rule → thêm test trước khi commit. Bug found in production → 1 regression test added before merge. Detail xem `docs/architecture.md §11` + `docs/rules.md §7`. +**Quy tắc timing test:** feature mới = test-after (UAT ổn → viết). Bug fix = test-before BẮT BUỘC (reproduce → fix). Critical algorithm (codegen/guard/financial/security) = test-before merge. Spec change = update test cũ + code chung commit. Skip: DTO mapping, CRUD master, FE snapshot. Detail `docs/rules.md §7`. ### CI/CD pipeline (3 fix lớn 29/04) diff --git a/docs/rules.md b/docs/rules.md index 1e71a1f..344c779 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -291,6 +291,16 @@ Co-Authored-By: Claude Opus 4.7 (1M context) ❌ 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 đủ)