Get the FREE Ultimate OpenClaw Setup Guide →

tdd-principles

npx machina-cli add skill kicchann/reqord/tdd-principles --openclaw
Files (1)
SKILL.md
2.1 KB

Good Test Principles (Khorikov's Theory)

This skill provides language-agnostic principles for writing high-value tests based on Vladimir Khorikov's "Unit Testing Principles, Practices, and Patterns".

When to Use This Skill

  • Writing or reviewing unit tests
  • Evaluating test quality
  • Designing testable architecture
  • Making decisions about test doubles (mocks/stubs)

Core Concept

The ultimate goal of unit testing is sustainable software growth, not just bug detection. Tests are assets that must provide more value than their maintenance cost.

Quick Reference

Four Pillars of Good Tests

  1. Protection Against Regressions - Bug detection effectiveness
  2. Resistance to Refactoring - Avoids false positives (MOST IMPORTANT)
  3. Fast Feedback - Quick execution
  4. Maintainability - Easy to understand and run

Test Style Hierarchy (Best -> Worst)

  1. Output-based - Verify return values only (pure functions)
  2. State-based - Verify state changes after operations
  3. Communication-based - Verify mock interactions (minimize use)

Classical Approach

  • Unit = Behavior unit (not class)
  • Isolate test cases from each other
  • Mock only shared dependencies
  • Use real instances for private dependencies

Resources

Read these in order for comprehensive understanding:

  1. resources/four-pillars.md - The Four Pillars in detail
  2. resources/classical-approach.md - Classical vs London school
  3. resources/test-styles.md - Output/State/Communication styles
  4. resources/mock-vs-stub.md - CQS-based test double usage

Integration with Other Skills

  • architecture-principles: Functional Core, Imperative Shell for testability
  • review-standards: Test quality review checklist
  • For language-specific implementation, see project-level skills in .claude/skills/

Source

git clone https://github.com/kicchann/reqord/blob/main/plugins/reqord/skills/tdd-principles/SKILL.mdView on GitHub

Overview

This skill codifies language-agnostic principles for writing high value unit tests based on Vladimir Khorikov. It covers the Four Pillars of Good Tests, the Classical vs London approaches, and the test style hierarchy. Use it when writing tests, reviewing test quality, or practicing TDD.

How This Skill Works

The skill provides actionable criteria: evaluate tests against the Four Pillars, classify tests by style (output, state, communication), and apply Classical versus London considerations when isolating units. Practitioners use these criteria to guide writing, reviewing, and refactoring for sustainable growth, fast feedback, and maintainability.

When to Use It

  • Writing or reviewing unit tests with value in mind
  • Evaluating test quality during code reviews
  • Designing testable architecture for new or existing code
  • Deciding which mocks or stubs to use in tests
  • Assessing tests during refactors to prevent false positives

Quick Start

  1. Step 1: Read the Four Pillars and the Test Style Hierarchy to frame your tests
  2. Step 2: Classify tests as output, state, or communication based on what they verify
  3. Step 3: Choose Classical or London approach and decide mocks and stubs accordingly

Best Practices

  • Align tests to the Four Pillars of Good Tests
  • Follow the Test Style Hierarchy from output to communication
  • Isolate unit tests and mock only shared dependencies
  • Prioritize fast feedback and easy maintenance
  • Use the Classical versus London guidance to balance realism and isolation

Example Use Cases

  • A refactoring of a module to remove brittle tests by focusing on output values
  • Replacing a brittle state check with a pure function output check to speed up tests
  • Introducing mocks for external services to isolate the unit under test
  • Auditing tests to avoid testing private implementation details
  • Using a Four Pillars checklist during PRs to assess test quality

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers