Decide Mock

When to mock. Real vs fake dependencies.

attac-t f4ef9bc 2 files · 3.3 KB Updated

File contents

Skill: Decide Mock

"Mock at the boundaries, not everywhere."

The Decision

Mock when:

  • External service (payment gateway, email provider)
  • Slow dependency (file system, network)
  • Non-deterministic (time, randomness)
  • You don't control it

Don't mock when:

  • In-process dependency (your own classes)
  • Database (use transactions instead)
  • The mock is more complex than the real thing
  • You're testing integration, not isolation

The Heuristic

Ask: "Does this cross a process boundary?"

Yes → Mock it. No → Use the real thing.

The Quick Test

Ask Answer Action
External API? Yes Mock
Your own class? Yes Real
Database? Yes Real + transaction
Time-dependent? Yes Freeze time
Non-deterministic? Yes Mock or seed

Real-World Examples

See examples.md.

attac-t/the-foundry/tree/main/plugins/pest/skills/decide-mock commit f4ef9bc50d

Frequently asked questions

npx skillmds@latest add attac-t/decide-mock