From ad4dae5f289390bb4b1457f5bfbf7db57a4324a4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 9 Jul 2026 19:40:01 +0200 Subject: [PATCH] :books: Add testing principles to serena doc --- .serena/memories/backend/core.md | 1 + .serena/memories/common/core.md | 1 + .serena/memories/common/testing-principles.md | 47 +++++++++++++++++++ .serena/memories/frontend/core.md | 1 + 4 files changed, 50 insertions(+) create mode 100644 .serena/memories/common/testing-principles.md diff --git a/.serena/memories/backend/core.md b/.serena/memories/backend/core.md index d815f69070..f416b78cf8 100644 --- a/.serena/memories/backend/core.md +++ b/.serena/memories/backend/core.md @@ -106,3 +106,4 @@ IMPORTANT: all CLI commands must be executed from the `backend/` subdirectory. * **Coverage:** If code is added or modified in `src/`, corresponding tests in `test/backend_tests/` must be added or updated. * **Isolated run:** `clojure -M:dev:test --focus backend-tests.my-ns-test` for a specific test namespace. * **Regression run:** `clojure -M:dev:test` to ensure no regressions in related functional areas. +* **Principles:** Cross-cutting testing principles, anti-patterns, and verification checklist: `mem:common/testing-principles`. diff --git a/.serena/memories/common/core.md b/.serena/memories/common/core.md index 474fb8d87e..23fbe20198 100644 --- a/.serena/memories/common/core.md +++ b/.serena/memories/common/core.md @@ -49,6 +49,7 @@ Components, variants, and debugging: Text and tests: - Shared text data conversion, DraftJS compatibility, modern text content, and derived position data: `mem:common/text-subtleties`. - Common test commands, helper conventions, production-path test mutations, and runtime coverage choices: `mem:common/testing`. +- Cross-cutting testing principles, anti-patterns, and verification checklist: `mem:common/testing-principles`. ## Areas without focused memories diff --git a/.serena/memories/common/testing-principles.md b/.serena/memories/common/testing-principles.md new file mode 100644 index 0000000000..860852393b --- /dev/null +++ b/.serena/memories/common/testing-principles.md @@ -0,0 +1,47 @@ +# Testing Principles (Cross-Cutting) + +Shared testing principles for all modules (backend, frontend, common, render-wasm, plugins). Module-specific commands and helpers are in each module's own testing memory. + +## Core Principles + +- **Test State, Not Interactions** — assert on outcomes, not method calls; survives refactoring +- **DAMP over DRY** — tests are specifications; duplication OK if each test is self-contained and readable +- **Prefer Real Implementations** — hierarchy: Real > Fake > Stub > Mock; mock only at boundaries (network, filesystem, email) +- **Arrange-Act-Assert** — every test: setup / action / verify +- **One Assertion Per Concept** — each test verifies one behavior; split compound assertions +- **Descriptive Test Names** — names read like specifications + +## Anti-Patterns + +- Testing implementation details → breaks on refactor +- Flaky tests (timing, order-dependent) → erode trust +- Mocking everything → tests pass, production breaks +- No test isolation → pass individually, fail together +- Testing framework code → waste of time +- Snapshot abuse → nobody reviews, break on any change + +## Verification Checklist + +After completing any implementation: +- Every new behavior has a corresponding test +- All tests pass for touched modules +- Bug fixes include a reproduction test that failed before the fix +- Test names describe the behavior being verified +- No tests were skipped or disabled + +## Red Flags + +- Writing code without corresponding tests +- Tests that pass on the first run (may not be testing what you think) +- Bug fixes without reproduction tests +- Tests that test framework behavior instead of app behavior +- Skipping tests to make the suite pass + +## Rationalizations + +- "I'll write tests after" → you won't; they'll test implementation not behavior +- "Too simple to test" → simple gets complicated; test documents expected behavior +- "Tests slow me down" → they speed up every future change +- "I tested manually" → manual testing doesn't persist +- "Code is self-explanatory" → tests ARE the specification +- "Just a prototype" → prototypes become production; test debt accumulates diff --git a/.serena/memories/frontend/core.md b/.serena/memories/frontend/core.md index 7edf80bbe1..b890de6770 100644 --- a/.serena/memories/frontend/core.md +++ b/.serena/memories/frontend/core.md @@ -52,6 +52,7 @@ Diagnostics and validation: - Source-edit compile/hot-reload diagnostics: `mem:frontend/compile-diagnostics`. - Runtime crash recovery: `mem:frontend/handling-crashes`. - Tests and live verification: `mem:frontend/testing`. +- Cross-cutting testing principles and anti-patterns: `mem:common/testing-principles`. - Real pointer/keyboard gesture reproduction: `mem:frontend/playwright-gestures`. ## Areas without focused memories