Not in the top 1,000 by GitHub stars

DanielCardonaRojas/swift-mocking

A compact swift mocking library powered by parameter packs.

History

Review weekly changes to SKILL.md before updating. Dates mark the weeks in which we observed each version; checks apply to the recorded commits.

View weekly changes

skills/swift-mocking/SKILL.md

Week of Oct 26, 2026 · Line counts unavailable

Before Not checked yet → After Network or broad shell

First observation → ed4e3c51abbb

No earlier version was observed for comparison.

Compare on GitHub

View on GitHubAdd to my skills

Verified commit ed4e3c51abbbc45d5f92c3645e53e0457dcc2b43

24GitHub stars
1star in 7 days
1skill in this repository
1commit in 30 days

Heat

2.6
  • Star growth, last 7 daysNot available
  • Star growth, last 24 hoursNot available
  • Rank movement, last 7 daysNot available
  • Commits, last 30 daysNot available
  • Accounts asking about it through MCP, last 7 daysNot available
  • Hot votes this weekNot available

Heat never changes the order by stars, and sponsorship never touches it. How heat works

Stars over time

Oct 25, 2026Nov 1, 202624

30-day change not yet available: not enough history.

Individual skills in this repository

How it works

swift-mocking

When your agent uses it

Use when writing Swift tests with the SwiftMocking library — creating @Mockable mocks, stubbing with when/verify, matching arguments, class-constrained protocols (@Mockable([.composition])), or hand-writing mocks (protocol inheritance chains, mocking classes).

What it loads into context

Frontmatter

59 tokens

Always available to the agent

SKILL.md

2,596 tokens

When the skill is activated

Reference documents

12,751 tokens

Loaded on request

Token counts are estimates. Scripts run separately; they are not counted as reference context.

The playbook

  1. When to use what
  2. API interface
  3. Deterministic generation: the `mockable` CLI
  4. The one rule for manual mocks
  5. Quick verification checklist
  6. Known sharp edges
  7. References

Files

  • SKILL.mdcore11,070 bytes
  • SKILL.mdcore11,070 bytes
  • SKILL.mdcore11,070 bytes
  • SKILL.mdcore11,070 bytes
  • SKILL.mdcore11,070 bytes
  • manual-mocking.mddoc18,874 bytes
  • references/interface/SwiftMocking.swiftinterfaceasset47,364 bytes
  • references/interface/SwiftMockingTestSupport.swiftinterfaceasset443 bytes
  • sendable.mddoc5,738 bytes
  • spies-and-composition.mddoc15,319 bytes
  • usage.mddoc12,452 bytes
Read SKILL.md

# SwiftMocking

Mocking for Swift protocols: `@Mockable` generates mock classes; `when(...)` stubs, `verify(...)` asserts calls. When the macro can't generate a mock — most notably **protocol inheritance** (`protocol B: A` — the macro drops inherited requirements and the mock fails to conform) — hand-write the mock following the exact generated-code shape.

The macro is not the only entry point. Two escape hatches cover everything it can't reach, and both are fully supported (see **spies-and-composition.md**):

- **`Spy` used directly** — a standalone recorder needing no `Mock` subclass and no macro. This is how you mock **classes**, which `@Mockable` cannot touch at all: subclass the class and back each override with a `Spy`.
- **Composition over inheritance** — hold a `let mock = Mock()` property instead of inheriting from `Mock`. `Mock`'s `@dynamicMemberLookup` subscript is `public`, so `mock.name` resolves spies from outside the class. Required when the type already has a superclass (`UIViewController`, a legacy base class) or isn't a class at all (**struct**, **actor**). Substitute `super.name` → `self.mock.name` and `adapt(...)` → `Mock.adapt(...)`; everything else in manual-mocking.md is unchanged.

**The macro generates the composed form itself** with `@Mockable([.composition])` — no hand-writing — when the blocker is a protocol whose conformers must inherit a class:

```swift
@Mockable([.composition])
protocol ViewControllerService: SampleBase { ... }
View the complete source on GitHub

Skills included

  • swift-mocking

Repository facts

License
MIT
Created
Jul 7, 2025
Last pushed
Oct 10, 2026
Forks
1
Open issues
0
Project activity
Active

Before you install

Network or broad shell

Automated signals, not a guarantee

Checked Nov 6, 2026

Not fully analyzed: some files were too long, unreadable or missing. This never lowers the level.

Show 4 notes
  • skills/swift-mocking/SKILL.md:1 Analysis incomplete: Referenced executable target unavailable; not analyzed
  • skills/swift-mocking/SKILL.md:1 Analysis incomplete: Referenced executable target unavailable; not analyzed
  • skills/swift-mocking/SKILL.md:1 Analysis incomplete: Referenced executable target unavailable; not analyzed
  • skills/swift-mocking/SKILL.md:1 Analysis incomplete: Referenced executable target unavailable; not analyzed
  • No broad tool permissions
  • No dangerous shell commands
  • 17 network referencesin 2 files: swift-mocking/usage.md:8 swift-mocking/SKILL.md:116
  • No hidden or obfuscated text
  • No instruction overrides
  • No executable scripts
  • No access to secrets
  • No requests to vote in Hot
Show all 17 signals by file

skills/swift-mocking/SKILL.md

  • Network accessline 116
    - Stub API is `thenReturn` / `thenThrow` / `do` — there is no `.then`. - **Never write `thenReturn(())`.** `Void` is in the default-value registry, so an unstubbed `-> Void` member just runs and records the call — stub it only to throw or t
  • Network accessline 117
    - **Never write `thenReturn(())`.** `Void` is in the default-value registry, so an unstubbed `-> Void` member just runs and records the call — stub it only to throw or to attach a `do` side effect. The registry also covers `Bool`/`String`/`
  • Network accessline 118
    - Spy names come from the requirement, ignoring argument labels: methods use their name, subscripts are namespaced as `subscript`+ParameterNames (`subscript(row:column:)` → `subscriptRowColumn`), settable members add `set`+Name. The prefix 

skills/swift-mocking/usage.md

  • Network accessline 8
    let mock = MyServiceMock()                    // generated: @Mockable protocol MyService when(mock.fetch(id: .any)).thenReturn(value)  // arrange — stub BEFORE use
  • Network accessline 9
    when(mock.fetch(id: .any)).thenReturn(value)  // arrange — stub BEFORE use
  • Network accessline 10
    let out = try await sut.fetch(id: "1")        // act — direct call routes through the spy
  • Network accessline 11
    verify(mock.fetch(id: .equal("1"))).called(1) // assert
  • Network accessline 105
    when(mock.execute(completion: .any)).do { completion in completion("ok") }     // side effect / callbacks when(mock.calculatePrice(.any)).thenReturn { item in prices[item] ?? 0 }      // dynamic return when(mock.fetch(.equal(url))).thenRetu
  • Network accessline 107
    when(mock.fetch(.equal(url))).thenReturn { _ in callCount == 1 ? throw Timeout : data } // stateful
  • Network accessline 124
    await verify(mock.upload(.any)).didThrow()      // async spies: await the didThrow() form verifyInOrder([mock.auth(.any), mock.data(.any)])  // call order across spies `called(n)` is synchronous for all effect types; only `.didThrow()` on a
  • Network accessline 126
    `called(n)` is synchronous for all effect types; only `.didThrow()` on async spies needs `await`. Verification failures are reported through [IssueReporting](https://github.com/pointfreeco/swift-issue-reporting) — they record issues inside 
  • Network accessline 192
    @Test func fetches() async throws {     let mock = MyServiceMock()     when(mock.fetch(id: .any)).thenReturn(User(id: "123"))
  • Network accessline 193
    let mock = MyServiceMock()     when(mock.fetch(id: .any)).thenReturn(User(id: "123"))     let user = try await SUT(mock).fetch(id: "123")
  • Network accessline 194
    when(mock.fetch(id: .any)).thenReturn(User(id: "123"))
  • Network accessline 195
    let user = try await SUT(mock).fetch(id: "123")
  • Network accessline 196
    #expect(user.id == "123")     await verify(mock.fetch(id: .equal("123"))).called(1) }
  • Network accessline 197
    await verify(mock.fetch(id: .equal("123"))).called(1)

How the signals fit together

Facts from a static read of the files at the pinned commit. They describe what the code does, not why.

Signal confidence: 17 facts

Works with

Agent compatibility, from the files in this repository
AgentStatusEvidenceInstall to
Claude CodeCompatibleStandard SKILL.md skills/swift-mocking/SKILL.md.claude/skills/<skill-name>/
CodexCompatibleStandard SKILL.md skills/swift-mocking/SKILL.md.agents/skills/<skill-name>/
CursorCompatibleStandard SKILL.md skills/swift-mocking/SKILL.md.cursor/skills/<skill-name>/
Gemini CLICompatibleStandard SKILL.md skills/swift-mocking/SKILL.md.gemini/skills/<skill-name>/
GitHub CopilotCompatibleStandard SKILL.md skills/swift-mocking/SKILL.md.github/skills/<skill-name>/
OpenCodeCompatibleStandard SKILL.md skills/swift-mocking/SKILL.md.opencode/skills/<skill-name>/
  • Native The repository ships a manifest, folder or frontmatter field for this agent.
  • Compatible A standard SKILL.md that this agent can read.
  • Unknown No evidence either way.

Derived automatically from paths, manifests and frontmatter. Not tested on each agent.