P282 · Workflow control

Prove behavioral RED before minimal GREEN

Verify that a behavioral test fails for the intended missing behavior before implementing the smallest change that passes it.

Editorially reviewed

These examples and illustrative results are independently authored teaching materials, not measured model results.

Use case

A form accepts empty email but must reject with required while valid input saves. Teaching submitEmail expects empty saved=false/error=required and valid saved=true. Prove the test detects missing behavior before implementing rather than mirroring current code afterward.

Mechanism

Assert observable behavior under real input and inspect failure on the old implementation. RED must be the target behavior/implementation, not unrelated import/syntax/environment errors. Make the same assertion pass minimally, run agreed project checks and refactor while green. Intended compile-time failures must genuinely express the target contract.

Bad example

Fix submitEmail first and test only that it can be called. Treat an import failure as behavioral RED and claim regression proof.

Good example

Assert empty input yields saved=false/error=required and a@example.test saved=true. Run the old implementation and confirm failure from actual empty-input saving, not setup. Implement the rule, rerun the same assertion and agreed suite checks, recording revisions and RED/GREEN output. No unexecuted test is evidence of sensitivity.

Why the change matters

An intended failure establishes defect sensitivity, and the same assertion passing connects repair to requirements. A non-crash test or import error does not establish that link.

Observable expectation

The teaching failure compares actual saved=true with expected false. GREEN requires empty/valid cases. Fix syntax/dependency problems before treating results as symptom evidence.

Match evidence to tested revisions and report other required failures; one green assertion is not all requirements.

Limits

Test value depends on behavior risk; avoid mechanical prose tests. Do not delete unrelated work to manufacture RED. This article designs assertions without a real form run.

Sources and evidence

Read the editorial criteria