Agent skill

Mocking Strategy

by revfactory in revfactory/harness-100

Test double (Mock, Stub, Spy, Fake) selection and effective mocking strategy guide.

Apache-2.0Auto-check passedTesting & QA

Install Mocking Strategy

skills CLI
$ npx skills add revfactory/harness-100 --skill mocking-strategy -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install revfactory/harness-100 mocking-strategy --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/revfactory/harness-100.git skills-src && mkdir -p .claude/skills && cp -r skills-src/en/24-test-automation/.claude/skills/mocking-strategy .claude/skills/mocking-strategy && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mocking-strategy
GitHub stars
1.3k
Token cost
~1.3k tokens
SKILL.md length
194 words
Files
1
Skills in repo
464
Repo updated
First seen
Licence
Apache-2.0

At a glance

Test double (Mock, Stub, Spy, Fake) selection and effective mocking strategy guide.

  • Dependency isolation
  • SKILL.md covers Test Double Type Comparison, Selection Decision Tree, Per-layer Mocking Strategy and Mocking Anti-patterns and…, plus 3 more sections
  • Reaches api.pg.com
  • External service mocking

What it does

Mocking Strategy is an agent skill from revfactory/harness-100. Test double (Mock, Stub, Spy, Fake) selection and effective mocking strategy guide. Use this skill for 'mocking', 'Mock', 'Stub', 'Spy', 'Fake', 'test doubles', 'dependency isolation', 'external service mocking', 'DB mocking', and other test isolation strategy tasks. Enhances the mocking design capabilities of unit-tester and integration-tester. Note: overall test strategy formulation and CI integration are outside the scope of this skill.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Unit testing. The licence is Apache-2.0.

When your agent uses it

  • Dependency isolation
  • External service mocking
  • Other test isolation strategy tasks

Example prompts

  • “mocking”
  • “test doubles”
  • “dependency isolation”
  • “/mocking-strategy”

Requirements

  • Python 3
  • Docker

What it can do on your machine

Read from SKILL.md and the folder at commit 8e8d35c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python, typescript and java).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.pg.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mocking Strategy loads about 1.3k tokens when it runs. Until then it costs about 115 tokens; SKILL.md has 194 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~115
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from revfactory/harness-100 at commit 8e8d35c, republished under its Apache-2.0 licence (© revfactory). 194 words, ~1,346 tokens.

Download SKILL.mdSave it as .claude/skills/mocking-strategy/SKILL.md (or your agent's skills folder).
name
mocking-strategy
description
Test double (Mock, Stub, Spy, Fake) selection and effective mocking strategy guide. Use this skill for 'mocking', 'Mock', 'Stub', 'Spy', 'Fake', 'test doubles', 'dependency isolation', 'external service mocking', 'DB mocking', and other test isolation strategy tasks. Enhances the mocking design capabilities of unit-tester and integration-tester. Note: overall test strategy formulation and CI integration are outside the scope of this skill.

Mocking Strategy — Test Double Selection and Mocking Strategy Guide

Methodologies for effectively isolating dependencies to create reliable tests.

Test Double Type Comparison

TypePurposeBehaviorVerification Target
DummyFill parametersDoes nothingNot used
StubProvide fixed responsesReturn predefined valuesState (result values)
SpyRecord callsReal behavior + recordingInteractions (call count/args)
MockDefine expected behaviorPass if expectations metInteractions (call order/args)
FakeLightweight implementationWorking simplified implementationState (integration level)

Selection Decision Tree

Need to isolate external dependencies
+-- Only need response values -> Stub
+-- Need to verify call occurrence/count -> Mock or Spy
|   +-- Also need real behavior -> Spy
|   +-- Real behavior not needed -> Mock
+-- Need a working lightweight implementation -> Fake
|   +-- e.g.: InMemoryRepository, FakeEmailSender
+-- Just need type matching -> Dummy

Per-layer Mocking Strategy

Repository/DB Layer
python
# Stub: Return fixed data
stub_repo = Mock(spec=UserRepository)
stub_repo.find_by_id.return_value = User(id=1, name="Test")

# Fake: In-memory implementation
class FakeUserRepository(UserRepository):
    def __init__(self):
        self._store = {}
    def save(self, user):
        self._store[user.id] = user
    def find_by_id(self, id):
        return self._store.get(id)
External API Layer
python
# HTTP mocking (responses / httpx_mock)
@responses.activate
def test_payment_api():
    responses.add(
        responses.POST, "https://api.pg.com/charge",
        json={"status": "success", "tx_id": "TX123"},
        status=200
    )
    result = payment_service.charge(10000)
    assert result.tx_id == "TX123"

# Timeout / Error simulation
responses.add(
    responses.POST, "https://api.pg.com/charge",
    body=ConnectionError("timeout")
)
Message Queue Layer
python
class FakeMessageBroker(MessageBroker):
    def __init__(self):
        self.published = []
    def publish(self, topic, message):
        self.published.append((topic, message))
    def assert_published(self, topic, expected_count=1):
        actual = [m for t, m in self.published if t == topic]
        assert len(actual) == expected_count
Time/Date Layer
python
# Time dependency injection
class OrderService:
    def __init__(self, clock=datetime.now):
        self.clock = clock

# Fixed time in tests
fixed_time = lambda: datetime(2024, 1, 1, 12, 0, 0)
service = OrderService(clock=fixed_time)

Mocking Anti-patterns and Solutions

Anti-patternProblemSolution
Over-mockingTests coupled to implementation detailsSwitch to behavior-based testing
Mock chainmock.a.b.c.d() deep mockingLaw of Demeter violation — refactor code
Mock hellMocking everythingReplace with Fakes, add integration tests
Repetitive setupSame Mock setup in every testIntroduce Fixture/Builder pattern
Excessive mock verificationOveruse of verify(mock, times(1)).method()Only verify essential interactions

Framework-specific Mocking Tools

Python
python
# unittest.mock
from unittest.mock import Mock, patch, MagicMock
# pytest-mock
def test_something(mocker):
    mocker.patch('module.Class.method', return_value=42)
# responses (HTTP)
# freezegun (time)
JavaScript/TypeScript
typescript
// Jest
jest.mock('./userService');
jest.spyOn(service, 'findUser').mockResolvedValue(mockUser);
// MSW (HTTP — service worker)
server.use(rest.get('/api/users', (req, res, ctx) => res(ctx.json([]))));
// Sinon (general purpose)
sinon.stub(db, 'query').resolves([]);
Java/Kotlin
java
// Mockito
@Mock UserRepository repo;
when(repo.findById(1L)).thenReturn(Optional.of(user));
verify(repo, times(1)).save(any(User.class));
// WireMock (HTTP)
// Testcontainers (real DB/Redis)

Testcontainers Usage (Fake Alternative)

python
# Isolate real DB with Docker — more realistic than Fakes
@pytest.fixture
def postgres():
    with PostgresContainer("postgres:16") as pg:
        engine = create_engine(pg.get_connection_url())
        yield engine

def test_user_crud(postgres):
    # Test with actual PostgreSQL
    repo = UserRepository(postgres)
    repo.save(User(name="test"))
    assert repo.find_by_name("test") is not None

Mocking Level Decision Matrix

Test TypeDBExternal APIMessage QueueFile System
Unit TestStub/MockStubMockStub
Integration TestFake/ContainerWireMockFaketmpdir
E2E TestReal DBSandbox APIReal queueReal FS

© revfactory, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in en/24-test-automation/.claude/skills/mocking-strategy of revfactory/harness-100.

Open the folder on GitHubat commit 8e8d35c

Compare with similar skills

Mocking Strategy next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mocking Strategy compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mocking Strategy this skillrevfactory/harness-1001.3k—~1.3kAutomated safety check: PassApache-2.0
TDD WorkflowhellangleZ/burn-in-cceverywhere-ralph11211 repos~2.4kAutomated safety check: PassNone
Testing OpenLogi UIAprilNEA/OpenLogi23k—~1.1kAutomated safety check: PassApache-2.0
Go Testingcxuu/golang-skills1701 repos~1.3kAutomated safety check: PassApache-2.0
Contractssamchon/nestia2.2k—~1.3kAutomated safety check: PassMIT
Cohesion Over TestabilityEpicenterHQ/epicenter4.8k—~2kAutomated safety check: PassCustom licence

Similar skills

  • TDD Workflow

    hellangleZ/burn-in-cceverywhere-ralph

    A skill your agent uses when writing new features, fixing bugs, or refactoring code.

    112 GitHub starsUsed in 11 repos~2.4k tokens
    Testing & QAAuto-check passed
  • Testing OpenLogi UI

    AprilNEA/OpenLogi

    Verifies OpenLogi's native GPUI interface with focused tests, the component gallery and a mock agent, choosing the evidence that fits each change.

    23k GitHub stars~1.1k tokensUpdated 3 days ago
    Testing & QAAuto-check passed
  • Go Testing

    cxuu/golang-skills

    A skill your agent uses when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff.

    170 GitHub starsUsed in 1 repo~1.3k tokens
    Testing & QAAuto-check passed
  • Contracts

    samchon/nestia

    Defines self-acknowledgments for production declarations and tests.

    2.2k GitHub stars~1.3k tokensUpdated today
    Testing & QAAuto-check passed
  • Cohesion Over Testability

    EpicenterHQ/epicenter

    Collapse test-shaped production boundaries while preserving behavior and coverage.

    4.8k GitHub stars~2k tokensUpdated today
    Testing & QAAuto-check passed
  • JS-in-HTML Testing

    liaohch3/claude-tap

    Tests JavaScript embedded in an HTML file in two layers: pytest checks of the logic ported to Python, and Playwright runs in a real browser for the DOM.

    3.3k GitHub stars~924 tokensUpdated 15 days ago
    Testing & QAAuto-check passed

More from revfactory/harness-100

All 464 skills in this repo
  • Anti Bot Analyzer

    revfactory/harness-100

    A skill for analyzing website anti-bot defense mechanisms and developing legitimate evasion strategies.

    1.3k GitHub stars~1.1k tokensUpdated 6 mo ago
    Auto-check passed
  • API Error Design Patterns

    revfactory/harness-100

    Reference for designing how an API reports failures: structured error codes, response shapes, client-friendly messages, an error catalog and retry or fallback advice.

    1.3k GitHub stars~1.6k tokensUpdated 6 mo ago
    Auto-check passed
  • API Security Checklist

    revfactory/harness-100

    Walks a backend-dev agent through OWASP API Top 10 checks, authentication and authorization patterns, and defense code during API design.

    1.3k GitHub stars~1.7k tokensUpdated 6 mo ago
    Auto-check passed
  • Arg Parser Generator

    revfactory/harness-100

    Methodology for systematically designing and generating CLI tool argument parser structures.

    1.3k GitHub stars~1.2k tokensUpdated 6 mo ago
    Auto-check passed
  • Audience Segmentation

    revfactory/harness-100

    Audience segmentation skill used by the analyst and curator agents.

    1.3k GitHub stars~1.3k tokensUpdated 6 mo ago
    Auto-check passed
  • Audio Storytelling

    revfactory/harness-100

    Audio storytelling skill used by the podcast scriptwriter and show note editor.

    1.3k GitHub stars~1.6k tokensUpdated 6 mo ago
    Auto-check passed

Categories

Questions about Mocking Strategy

What does Mocking Strategy do?

Test double (Mock, Stub, Spy, Fake) selection and effective mocking strategy guide. Mocking Strategy is an agent skill from revfactory/harness-100. Test double (Mock, Stub, Spy, Fake) selection and effective mocking strategy guide.

When should I use Mocking Strategy?

Mocking Strategy fits situations like: dependency isolation; external service mocking; other test isolation strategy tasks.

How do I install Mocking Strategy in Claude Code?

Run `npx skills add revfactory/harness-100 --skill mocking-strategy -a claude-code`. Or copy the skill folder (en/24-test-automation/.claude/skills/mocking-strategy in revfactory/harness-100) into .claude/skills/mocking-strategy in your project. Claude Code loads it when a task matches its description.

How do I install Mocking Strategy in Codex?

Run `npx skills add revfactory/harness-100 --skill mocking-strategy -a codex`. Or copy the skill folder (en/24-test-automation/.claude/skills/mocking-strategy in revfactory/harness-100) into .agents/skills/mocking-strategy in your project. Codex loads it when a task matches its description.

Can I use Mocking Strategy in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add revfactory/harness-100 --skill mocking-strategy -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mocking-strategy, .gemini/skills/mocking-strategy, .github/skills/mocking-strategy and .opencode/skills/mocking-strategy in your project.

What does Mocking Strategy need to run?

SKILL.md names no scripts, command-line tools or credentials: Mocking Strategy is instructions for the agent only. Our summary lists: Python 3; Docker.

Does Mocking Strategy access the network?

SKILL.md names 1 domain. In commands or code: api.pg.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Mocking Strategy safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Mocking Strategy use?

Mocking Strategy is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mocking Strategy use?

About 1.3k tokens (SKILL.md is roughly 5.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Mocking Strategy?

Skills that share tags, products or a category with Mocking Strategy: TDD Workflow (hellangleZ/burn-in-cceverywhere-ralph, 112 stars), Testing OpenLogi UI (AprilNEA/OpenLogi, 23k stars), Go Testing (cxuu/golang-skills, 170 stars) and Contracts (samchon/nestia, 2.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mocking Strategy?

revfactory (a GitHub user) maintains it in revfactory/harness-100, which has 1,290 GitHub stars. The repository holds 464 skills in this directory. The repository was last updated on March 22, 2026.

Source: revfactory/harness-100 on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.