docs: red-green rule for bug fixes; regenerate traceability matrix
CLAUDE.md now states the failing-test-first rule explicitly: write a test that reproduces the bug and watch it fail before applying the fix, and extract buried logic into a plain .ts module so it can be unit-tested. A test written against already-fixed code can pass for the wrong reason.
This commit is contained in:
@@ -266,6 +266,23 @@ tagged responses keep the Rust field names as-is (e.g. `new_url`, not `newUrl`).
|
|||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|
### 🔴 Bug fixes: failing test FIRST, then the fix
|
||||||
|
|
||||||
|
When fixing a bug, **write a test that reproduces it and watch it fail before
|
||||||
|
touching the fix.** Red → green, in that order:
|
||||||
|
|
||||||
|
1. Write a test that exercises the broken behavior and **run it — it must fail**,
|
||||||
|
proving the test actually catches the bug (a test that passes before the fix
|
||||||
|
proves nothing).
|
||||||
|
2. Apply the fix.
|
||||||
|
3. Re-run — the test now passes, and so does the rest of the suite.
|
||||||
|
|
||||||
|
Never fix first and backfill the test afterward: a test written against
|
||||||
|
already-fixed code can pass for the wrong reason and silently fails to guard the
|
||||||
|
regression. If the logic is buried in a component, extract the pure part into a
|
||||||
|
plain `.ts` module (e.g. `episodeStrip.ts`) so it can be unit-tested — the same
|
||||||
|
pattern as `TrackList.logic.test.ts`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Rust
|
# Rust
|
||||||
cd src-tauri && cargo test
|
cd src-tauri && cargo test
|
||||||
|
|||||||
+558
-480
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user