From 019db5f9677902ba02d703a8554667d1b6e88f6b Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 19 Apr 2026 12:36:04 -0500 Subject: refactor: generalize testing.md, split Python specifics, DRY install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit claude-rules/testing.md is now language-agnostic (TDD principles, test categories, coverage targets, anti-patterns). Scope header widened to **/*. Python-specific content (pytest, fixtures, parametrize, anyio, Django DB testing) moved to languages/python/claude/rules/python-testing.md. Added languages/python/ bundle (rules only so far; no CLAUDE.md template or hooks yet — Python validation tooling differs from Elisp). Added install-python shortcut to the Makefile. Updated scripts/install-lang.sh to copy claude-rules/*.md into each target project's .claude/rules/. Bundles no longer need to carry their own verification.md copy — deleted languages/elisp/claude/rules/verification.md. Single source of truth in claude-rules/, fans out via install. Elisp-testing.md now references testing.md as its base (matches the python-testing.md pattern). --- claude-rules/testing.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'claude-rules') diff --git a/claude-rules/testing.md b/claude-rules/testing.md index 37ba412..42cc528 100644 --- a/claude-rules/testing.md +++ b/claude-rules/testing.md @@ -1,6 +1,10 @@ # Testing Standards -Applies to: `**/*.py`, `**/*.ts`, `**/*.tsx`, `**/*.js`, `**/*.jsx` +Applies to: `**/*` + +Core TDD discipline and test quality rules. Language-specific patterns +(frameworks, fixture idioms, mocking tools) live in per-language testing files +under `languages//claude/rules/`. ## Test-Driven Development (Default) @@ -56,6 +60,8 @@ Every unit under test requires coverage across three categories: ## Test Organization +Typical layout: + ``` tests/ unit/ # One test file per source file @@ -63,14 +69,21 @@ tests/ e2e/ # Full system tests ``` +Per-language files may adjust this (e.g. Elisp collates ERT tests into +`tests/test-*.el` without subdirectories). + ## Naming Convention - Unit: `test____` - Integration: `test_integration___` Examples: -- `test_satellite_calculate_position_null_input_raises_error` -- `test_integration_telemetry_sync_network_timeout_retries_three_times` +- `test_cart_apply_discount_expired_coupon_raises_error` +- `test_integration_order_sync_network_timeout_retries_three_times` + +Languages that prefer camelCase, kebab-case, or other conventions keep the +structure but use their idiom. Consistency within a project matters more than +the specific case choice. ## Test Quality @@ -100,7 +113,7 @@ Mock external dependencies at the system boundary: Never mock: - The code under test - Internal domain logic -- Framework behavior (ORM queries, middleware, hooks) +- Framework behavior (ORM queries, middleware, hooks, buffer primitives) ## Coverage Targets -- cgit v1.2.3