mocking

Mock external dependencies in C tests using MOCKABLE weak symbol wrappers.

Updated Mar 4, 2026
One-click install
npx skills add https://github.com/multicam/ikigai-rev --skill mocking-multicam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mocking
Source: https://github.com/multicam/ikigai-rev/tree/main/.claude-i/library/mocking
Command: npx skills add https://github.com/multicam/ikigai-rev --skill mocking-multicam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

MOCKABLE wrappers enable zero-overhead mocking for external dependencies in tests, allowing tests to run without touching real libraries and system calls, while keeping production code clean.

Core Features & Use Cases

  • MOCKABLE Pattern: wrappers via weak symbols to allow tests to override behavior without changing production code.
  • Testability Boost: override external dependencies, simulate failures, and exercise edge cases reliably.
  • Supported Wrappers: includes POSIX, POSIX stdio, C standard library, talloc, yyjson, and libcurl wrappers for deterministic testing.

Quick Start

Include the wrapper.h in tests and override the weak symbols in your test files to simulate failures or specific behaviors.

Frequently Asked Questions about mocking

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

FAQPage Schema
How do I mock external dependencies in C unit tests without changing production code?

You can mock external dependencies in C unit tests by declaring functions with a MOCKABLE macro and overriding the weak symbols in your test files, keeping production code untouched.

How does weak symbol mocking work for testing C libraries?

Weak symbol mocking works by defining wrapper functions that tests override at link time, allowing you to replace runtime behavior of C libraries without modifying the original source code.

Can I simulate failure modes for system calls and libcurl in C tests?

Yes, you can simulate failure modes by overriding the provided POSIX, stdio, C standard library, and libcurl wrappers in your test files to exercise edge cases reliably.

What do I need to set up before using MOCKABLE wrappers in my C project?

You need a C compiler with weak symbol support and a MOCKABLE macro declaration for each target function, plus per-function wrappers to be overridden in your test files.

Does zero-overhead mocking work with talloc and yyjson dependencies?

Yes, zero-overhead mocking works with talloc and yyjson by including the provided wrapper headers in tests and overriding the weak symbols to simulate specific behaviors.

When should I avoid using weak symbols for mocking in C?

You should avoid weak symbol mocking when your compiler lacks weak symbol support or when production code cannot accommodate the required MOCKABLE macro declarations.