Regression Testing
Purpose
Stop fixed bugs from coming back and protect critical behaviors from silent breakage: a regression test per bug (written failing, then passing) and a maintained suite that gates every change.
When to Use
- After every bug fix (
../../bug-investigation closes with a regression test).
- When protecting a critical behavior from future refactors.
- Not as a separate late phase — regression tests are written with each fix, at the right level.
Inputs
- The bug's root cause + reproduction (
../../bug-investigation).
- The test level that reproduces it (unit / integration / API / E2E).
Discovery Questions
- What is the minimal reproduction, and at what level does it live (prefer the lowest)?
- Does the test fail before the fix and pass after (proving it guards the right thing)?
- Is this class of bug likely elsewhere (parametrize/broaden the guard)?
Responsibilities
- Take the behavior to be covered from its Gherkin scenarios (
gherkin-specifications) — implement one test per scenario rather than inventing a parallel case list.
- For each fixed bug, write a test that reproduces it and fails on the unfixed code, then passes with the fix — at the lowest level that captures it (unit if logic, integration if wiring, API if endpoint, E2E only if genuinely end-to-end).
- Name the test for the bug/behavior it guards so a future failure is self-explaining.
- Maintain a regression suite as part of the normal test suites (not a separate silo), run in CI on every change (
../../devops/ci-cd) — a regression test that isn't run guards nothing.
- Broaden where a bug reveals a class (boundary families, all enum values) rather than pinning one input.
- Keep regression tests behavioral (outcomes), so they survive refactors and still catch the reintroduction.
Required Workflow
- Reproduce the bug at the lowest capturing level.
- Write the test; confirm it fails on unfixed code.
- Apply/confirm the fix; the test now passes.
- Generalize if it's a class of bug.
- Land it in the CI-gated suite alongside the fix.
Decision Rules
- Lowest level that reproduces — a unit regression beats an E2E one for the same bug (faster, stabler).
- A regression test that passes before the fix isn't testing the fix — it must fail first.
- Behavioral assertions over implementation snapshots, so refactors don't force rewrites that lose the guard.
- No fix merges without its regression test (
../../code-review gate).
Rules
- Every bug fix ships with a failing-first regression test.
- Regression tests run in CI, not on demand.
- Guards are named for what they protect.
Anti-Patterns
- Fixing a bug with no test — inviting its return.
- A regression test that never failed (proves nothing).
- Snapshot regressions that break on every refactor and get blanket-updated.
- A separate regression suite nobody runs.
- Pinning one input when the bug is a whole boundary class.
Validation Checklist
Definition of Done
Every fixed bug guarded by a failing-first, behavioral regression test at the lowest capturing level, living in the CI-gated suite so the breakage cannot silently return.
Related Skills
../../bug-investigation, unit-testing, integration-testing, api-integration-testing, test-coverage-audit, ../../code-review, ../../devops/ci-cd, ../../security/security-regression-testing.
Related Knowledge
../../../knowledge/ (past incidents, critical behaviors).
Related References
../../../references/testing/ (regression patterns, when populated).
Context Loading Guidance
- Requires: the bug's root cause + reproduction, the capturing level.
- Does not require: the whole test suite, unrelated modules.
- May load: the matching level skill (
unit-testing/integration-testing/...).
- Stop when: the failing-first test is in the CI-gated suite.
Token Efficiency Guidance
One test per bug at the right level; reason about the reproduction, not the surrounding suite.
1---2name: regression-testing3description: Use to ensure every fixed bug and every critical behavior stays fixed — a failing-first test per bug at the lowest level that reproduces it, plus a maintained regression suite gating CI so old breakage can't silently return.4---56# Regression Testing78## Purpose910Stop fixed bugs from coming back and protect critical behaviors from silent breakage: a **regression test per bug** (written failing, then passing) and a maintained suite that gates every change.1112## When to Use1314- After every bug fix (`../../bug-investigation` closes with a regression test).15- When protecting a critical behavior from future refactors.16- **Not** as a separate late phase — regression tests are written *with* each fix, at the right level.1718## Inputs1920- The bug's root cause + reproduction (`../../bug-investigation`).21- The test level that reproduces it (unit / integration / API / E2E).2223## Discovery Questions2425- What is the minimal reproduction, and at what level does it live (prefer the lowest)?26- Does the test **fail before** the fix and **pass after** (proving it guards the right thing)?27- Is this class of bug likely elsewhere (parametrize/broaden the guard)?2829## Responsibilities3031- Take the behavior to be covered from its **Gherkin scenarios** (`gherkin-specifications`) — implement one test per scenario rather than inventing a parallel case list.32- For each fixed bug, write a test that **reproduces it and fails on the unfixed code**, then passes with the fix — at the **lowest level** that captures it (unit if logic, integration if wiring, API if endpoint, E2E only if genuinely end-to-end).33- Name the test for the bug/behavior it guards so a future failure is self-explaining.34- **Maintain a regression suite** as part of the normal test suites (not a separate silo), run in CI on every change (`../../devops/ci-cd`) — a regression test that isn't run guards nothing.35- Broaden where a bug reveals a class (boundary families, all enum values) rather than pinning one input.36- Keep regression tests **behavioral** (outcomes), so they survive refactors and still catch the reintroduction.3738## Required Workflow39401. Reproduce the bug at the lowest capturing level.412. Write the test; confirm it **fails** on unfixed code.423. Apply/confirm the fix; the test now passes.434. Generalize if it's a class of bug.445. Land it in the CI-gated suite alongside the fix.4546## Decision Rules4748- Lowest level that reproduces — a unit regression beats an E2E one for the same bug (faster, stabler).49- A regression test that passes before the fix isn't testing the fix — it must fail first.50- Behavioral assertions over implementation snapshots, so refactors don't force rewrites that lose the guard.51- No fix merges without its regression test (`../../code-review` gate).5253## Rules5455- Every bug fix ships with a failing-first regression test.56- Regression tests run in CI, not on demand.57- Guards are named for what they protect.5859## Anti-Patterns6061- Fixing a bug with no test — inviting its return.62- A regression test that never failed (proves nothing).63- Snapshot regressions that break on every refactor and get blanket-updated.64- A separate regression suite nobody runs.65- Pinning one input when the bug is a whole boundary class.6667## Validation Checklist6869- [ ] Each fixed bug has a test at the lowest capturing level.70- [ ] Test fails on unfixed code, passes after fix.71- [ ] Named for the guarded bug/behavior.72- [ ] Generalized where it's a class.73- [ ] In the CI-gated suite.7475## Definition of Done7677Every fixed bug guarded by a failing-first, behavioral regression test at the lowest capturing level, living in the CI-gated suite so the breakage cannot silently return.7879## Related Skills8081`../../bug-investigation`, `unit-testing`, `integration-testing`, `api-integration-testing`, `test-coverage-audit`, `../../code-review`, `../../devops/ci-cd`, `../../security/security-regression-testing`.8283## Related Knowledge8485`../../../knowledge/` (past incidents, critical behaviors).8687## Related References8889`../../../references/testing/` (regression patterns, when populated).9091## Context Loading Guidance9293- **Requires:** the bug's root cause + reproduction, the capturing level.94- **Does not require:** the whole test suite, unrelated modules.95- **May load:** the matching level skill (`unit-testing`/`integration-testing`/...).96- **Stop when:** the failing-first test is in the CI-gated suite.9798## Token Efficiency Guidance99100One test per bug at the right level; reason about the reproduction, not the surrounding suite.