| name | outside-in-tdd |
| description | Use when writing tests from the outside-in, defining behavior before code, or any feature where tests should start from observable business behavior and let internal design emerge |
Outside-In DDD Testing
Overview
Complete testing guide for outside-in development.
Start from observable behavior (Gherkin), let design emerge from tests.
Core rule: Real domain objects, mocked external boundaries, fast in-memory tests.
Outside-In Approach
Prerequisite: Gherkin scenarios must be written and approved before this skill applies. This includes new features, bug fixes, and behavior-changing refactoring. If Gherkin scenarios are already approved for the current task, proceed directly to Step 1 — gherkin-gate is already done.
REQUIRED SUB-SKILL: superpowers-whetstone:gherkin-gate — run first, wait for approval, then return here.
Step 1: Map Scenario to Acceptance Test
- Map Gherkin to test — translate scenario to a top-level acceptance-style test
- Write the test — mock only external boundaries, use real domain objects
Step 2: Let Domain Emerge
STOP. Do NOT create any domain class, value object, entity, policy, or enum before your first test fails to compile. Design MUST emerge from red — not from upfront thinking. Even if you already know the domain from context, create nothing until the test's compilation failure confirms what's needed. This includes adding 'just a new variant' of something that already exists: a new vehicle type, a new rejection reason, a new value object field, or a new boundary value — even if similar ones already exist in the codebase. Wait for the test's compilation failure before creating the new type.
Test failures reveal the domain you need. Let the design emerge from failing tests — don't design upfront.
- Domain objects (policies, value objects, services) emerge from what the test demands