Command Palette

Search for a command to run...

Назад к скиллам
скилл № 68844

test-doubles-strategy

Choosing between mocks, stubs, fakes, spies, and dummies based on testing needs.

БесплатноБез исполняемых скриптов
sethdfordот sethdford★ 51 звезда на GitHub

Установить test-doubles-strategy в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Test Doubles Strategy

Strategies for replacing real objects with test doubles.

Context

You are selecting the right test double for the job. Understand the tradeoffs of each approach.

Domain Context

  • Stub: Returns canned answers; doesn't care how many times it's called
  • Mock: Expects specific calls; verifies behavior
  • Fake: Lightweight working implementation; slower but more realistic than stub
  • Spy: Records calls; can verify and allow through to real object
  • Dummy: Placeholder; passed but never used

Instructions

  1. Stub: Use when you need predictable return values; database returning test data
  2. Mock: Use when you need to verify that a dependency was called correctly
  3. Fake: Use for database or third-party service; test containers are modern fakes
  4. Spy: Use when you need both verification and real behavior
  5. Dummy: Use when dependency is required by signature but not used
  6. Avoid Over-Mocking: If everything is mocked, you're not testing integration
  7. Prefer Fakes: Modern practice uses test containers over mocks for external services

Anti-Patterns

  • Mocking everything; you need at least some real code to test
  • Over-specifying mocks; brittle tests that fail on implementation changes
  • Mocking your own code; mock external dependencies, not your logic
  • Complex mock setup that's harder than the test; use factories or test builders
  • Never testing error paths through mocks; ensure your error handling actually works

Further Reading

  • Martin Fowler, Test Double essay
  • Gerard Meszaros, xUnit Test Patterns

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл test-doubles-strategy?

Choosing between mocks, stubs, fakes, spies, and dummies based on testing needs.

Как установить скилл test-doubles-strategy?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл test-doubles-strategy запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить test-doubles-strategy с