feat(bdd): add tautological-test anti-pattern and pre-agreed-seams step

- feat(bdd): step 0.5 — seams under test confirmed before any test exists
- feat(bdd): tautological-test anti-pattern — expected values from independent truth
- docs(bdd): note the deliberate refactor-inside-loop divergence from upstream
This commit is contained in:
Łukasz Boryń 2026-07-19 23:25:23 +02:00
parent 18d48ce850
commit dcec931589
2 changed files with 37 additions and 15 deletions

View File

@ -16,20 +16,16 @@ description: Drive implementation with a strict red-green-refactor loop where ev
Before step 1, anchor on [../codebase-design/SKILL.md](../codebase-design/SKILL.md) — Before step 1, anchor on [../codebase-design/SKILL.md](../codebase-design/SKILL.md) —
module, interface, seam, adapter, depth, leverage, locality. module, interface, seam, adapter, depth, leverage, locality.
## Language references — Python ## Language references
Pytest only — `@pytest.fixture`, `parametrize`, scenario as docstring. **Python** (pytest only — fixtures, `parametrize`, scenario as docstring):
- [tests-py.md](tests-py.md) — paired good/bad examples. [tests-py.md](tests-py.md), [interface-design-py.md](interface-design-py.md)
- [interface-design-py.md](interface-design-py.md) — DI, pure functions, typing. *Before step 1.* (*before step 1*), [mocking-py.md](mocking-py.md) (*before `patch` /
- [mocking-py.md](mocking-py.md) — seams only, façade + DI over patching. *Before `patch` / `monkeypatch`.* `monkeypatch`* — seams only, façade + DI), [docstrings-py.md](docstrings-py.md).
- [docstrings-py.md](docstrings-py.md) — Google style, types in annotations not prose. **R** (testthat ed. 3+, `box::use`, `describe`/`it`):
[tests-r.md](tests-r.md), [interface-design-r.md](interface-design-r.md)
## Language references — R (*before step 1*), [deep-modules-r.md](deep-modules-r.md),
Testthat ed. 3+, `box::use`, `describe`/`it`. [mocking-r.md](mocking-r.md) (*before `mockery::stub`* — seams only),
- [tests-r.md](tests-r.md) — paired good/bad examples. [refactoring-r.md](refactoring-r.md) (*step 3*).
- [interface-design-r.md](interface-design-r.md) — DI, pure functions, minimal surface. *Before step 1.*
- [deep-modules-r.md](deep-modules-r.md) — small interface, large impl.
- [mocking-r.md](mocking-r.md) — seams only. *Before `mockery::stub` / `local_mocked_bindings`.*
- [refactoring-r.md](refactoring-r.md) — what to look for in step 3.
## Process ## Process
@ -48,6 +44,13 @@ Testthat ed. 3+, `box::use`, `describe`/`it`.
- The scenarios are a **plan**, not a batch of tests to write upfront. See - The scenarios are a **plan**, not a batch of tests to write upfront. See
the horizontal-slicing anti-pattern below. the horizontal-slicing anti-pattern below.
### 0.5 Agree the seams
- Write down the **seams under test** and confirm them with the user
before any test exists — no test at an unconfirmed seam. Up-front
agreement puts effort on critical paths, not every edge. Inside
[implement](../../loop/implement/SKILL.md), the spec's *Seams touched*
pre-answers this — reuse it.
### 1. Red — one scenario at a time ### 1. Red — one scenario at a time
- Translate **only the first** scenario into the project's native test - Translate **only the first** scenario into the project's native test
framework (pytest, testthat, vitest, go test, …). Leave the rest as framework (pytest, testthat, vitest, go test, …). Leave the rest as
@ -94,9 +97,12 @@ each finding ([refute.md](../review-angles/refute.md)); fix red-test-first.
## Guardrails ## Guardrails
- **Never** skip red, write >1 failing test at once, or refactor while red. - **Never** skip red, write >1 failing test at once, or refactor while red.
- **Never** test at a seam the user hasn't confirmed (step 0.5).
- A scenario untestable at the chosen level gets surfaced, not dropped. - A scenario untestable at the chosen level gets surfaced, not dropped.
- Refactor stays **inside** the loop (step 3) — deliberate divergence
from upstream tdd; octobot's reviews are a separate post-green pass.
See [anti-patterns.md](anti-patterns.md) — horizontal slicing, passing on See [anti-patterns.md](anti-patterns.md) — horizontal slicing, passing on
first run, refactoring while red, dropping an untestable scenario. first run, tautological tests, refactoring while red, dropped scenarios.
## See also ## See also
- [../diagnose/SKILL.md](../diagnose/SKILL.md) — chasing an existing bug? - [../diagnose/SKILL.md](../diagnose/SKILL.md) — chasing an existing bug?

View File

@ -24,6 +24,22 @@ test is testing the wrong thing — the behavior was already present, or the
assertion is a tautology. Fix the test before continuing. Never let a green assertion is a tautology. Fix the test before continuing. Never let a green
bar on a brand-new test go unchallenged. bar on a brand-new test go unchallenged.
## Tautological tests
An assertion that recomputes the expected value the way the code does can
never disagree with the code — it passes by construction:
```python
assert add(a, b) == a + b # recomputed the same way — tautology
assert config == load_config() # snapshot derived by the code itself
```
Expected values come from an **independent source of truth**: a
known-good literal, a worked example done by hand, the spec's stated
semantics (`OKF/specs/NNN`). If you can't produce the expectation without
running the code under test, you don't have a test yet. (Adapted from
mattpocock/skills tdd.)
## Refactoring while red ## Refactoring while red
If the suite is red, fix the test or fix the code — do not "tidy while If the suite is red, fix the test or fix the code — do not "tidy while