unit-testing-principles

Evaluates unit test quality using Khorikov's four pillars and mocking heuristics.

1|Updated May 21, 2026
One-click install
npx skills add https://github.com/vnovakovits/claude-skills --skill unit-testing-principles-vnovakovits
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: unit-testing-principles
Source: https://github.com/vnovakovits/claude-skills/tree/main/plugins/engineering-practices/skills/unit-testing-principles
Command: npx skills add https://github.com/vnovakovits/claude-skills --skill unit-testing-principles-vnovakovits

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Test suites often become brittle, breaking on every refactor while providing little real protection against regressions. This Skill applies Vladimir Khorikov's framework from "Unit Testing Principles, Practices, and Patterns" to evaluate whether tests are actually good, decide what to mock, and choose the right testing style. ## Core Features & Use Cases - Four Pillars Evaluation: Assess tests against protection against regressions, resistance to refactoring, fast feedback, and maintainability, including their unavoidable trade-offs. - Mocking Heuristics: Apply the managed vs unmanaged dependency distinction to decide what to mock, plus strict rules for mocks vs stubs and the three testing styles (output-based, state-based, communication-based). - Use Case: When reviewing a PR full of mock-heavy tests that verify internal calls, use this Skill to identify over-specification, refactor communication-based tests into state-based ones, and move mocks to unmanaged dependency boundaries like payment gateways. ## Quick Start Ask Claude to review your test suite against Khorikov's unit testing principles and identify brittle or low-value tests.

Frequently Asked Questions about unit-testing-principles

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decide what to mock in unit tests?▼

Mock only unmanaged dependencies like payment gateways, email services, and third-party APIs whose contracts you do not own. Managed dependencies such as your application's database should be tested with real instances or in-memory fakes in integration tests.

What is the difference between mocks and stubs in unit testing?▼

Stubs substitute incoming queries with canned data, while mocks verify outgoing commands were issued. Never verify calls on stubs, since that over-specifies the test and couples it to implementation details rather than observable outcomes.

Why do my unit tests break on every refactor?▼

Tests break on refactoring when they assert on implementation details like private state, internal call sequences, or mocked internal classes. Fix this by asserting only on observable behavior that any reasonable alternative implementation could satisfy.

Should I use unit tests or integration tests for controllers?▼

Controllers are low-significance orchestration code best covered by integration tests with one happy path each. Unit-testing a controller usually requires mocking everything, producing low-value communication-based tests with weak regression protection.

Is high code coverage a good target for test suites?▼

Code coverage should never be a target because it does not measure regression protection. A suite with 100% coverage of trivial code and mocked interactions protects less than 60% coverage of high-significance domain logic tested at observable boundaries.