Core Concepts
Foundational concepts for Behavior-Driven Development and testing
Understand the principles and practices that underpin specification-driven development.
Overview
This section covers:
- Three-Layer Approach - Rules, Scenarios, and Unit Tests working together
- BDD Fundamentals - Behavior-Driven Development principles and Gherkin
- Executable Specifications - Living documentation that drives development
- Specifications Evolution - How specifications change over time
- Canon TDD Workflow - Test-Driven Development cycle
- Ubiquitous Language - Shared vocabulary for domain understanding
In This Section
| Topic | Description |
|---|---|
| Three-Layer Approach | Rules, Scenarios, and Unit Tests hierarchy |
| BDD Fundamentals | Behavior-Driven Development and Gherkin syntax |
| Executable Specifications | Living documentation as automated tests |
| Specifications Evolution | How specifications change with understanding |
| Canon TDD Workflow | Test-Driven Development cycle (Red-Green-Refactor) |
| Ubiquitous Language | Domain-specific shared vocabulary |
Key Principles
1. Specifications are executable
Specifications aren't just documentation - they're automated tests that verify system behavior.
Scenario: User creates a project
Given I am in an empty directory
When I run "r2r init my-project"
Then a file named "my-project/r2r.yaml" should exist
This scenario is both documentation AND an automated test.
2. Three layers of testing
Each layer serves a distinct purpose:
- Rules define measurable business requirements
- Scenarios provide concrete examples
- Unit Tests verify implementation details
3. Ubiquitous Language
Use domain terms consistently across specifications, code, and conversations:
- ✅ "release" (domain term)
- ❌ "deployment" (technical term)
4. Specifications evolve
Specifications are living documents that improve through:
- Discovery (Event Storming, Example Mapping)
- Implementation (edge cases, refinement)
- Feedback (bugs, production issues)
Quick Start
New to BDD?
- Start here: BDD Fundamentals - Understand Given/When/Then
- Learn the structure: Three-Layer Approach - How Rules/Scenarios/Tests work together
- Discover requirements: Example Mapping - Workshop technique for finding acceptance criteria
- Write specifications: Organizing Specifications - File structure and naming conventions
Common Workflows
Test-Driven Development:
- Write failing scenario (Red)
- Write step definitions
- Implement minimal code (Green)
- Refactor
- Commit
See: Canon TDD Workflow
Specification-First Development:
- Run Example Mapping workshop
- Write feature with Rules and Scenarios
- Implement step definitions
- Write unit tests
- Implement production code
Related Documentation
Workshop Techniques
- Event Storming - Discover domain events and language
- Example Mapping - Discover acceptance criteria with colored cards
Organization
- Organizing Specifications - File structure and naming conventions
- Testing Taxonomy - Tags, test levels, and execution control
Implementation
- Go Implementation Guide - Go/Godog BDD implementation
- Quality & Maintenance - Review and iterate on specifications
Tutorials | How-to Guides | Explanation | Reference
You are here: Explanation — understanding-oriented discussion that clarifies concepts.