# Testability

> Testability assessment criteria for code review. Apply when writing new code that will be tested or evaluating code for dependency injection, global state, pure functions, and test seams. Use when this capability is needed.

- Skill: `tomevault-io/testability-3` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/testability-3`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/testability-3/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/testability-3

---


# Testability Assessment

Evaluate whether code can be effectively unit tested in isolation.

**Layers**:
- `rules.md` - Quick reference and severity guidance
- `examples.md` - Detailed code examples

## Quick Reference

| Factor | Question | Severity if problematic |
|--------|----------|------------------------|
| Dependency injection | Are deps passed in? | High |
| Global state | Is shared state avoided? | High |
| Pure functions | Is logic separated from I/O? | Medium |
| Time/randomness | Are these injectable? | Medium |
| File system | Can it be abstracted? | Medium |
| Seams | Can behavior be substituted? | Medium-High |
| Observability | Can you assert on outputs? | Medium |
| Mock avoidance | Does the design eliminate the need for mocking? | High |

## Quick Heuristic

If testing a function requires:
- **0 mocks**: Excellent testability (pure function)
- **1-2 mocks**: Acceptable (clear external boundaries only)
- **3-5 mocks**: Redesign required (too many responsibilities or mocking internal code)
- **6+ mocks**: Design failure (refactor before writing tests)

If any mock or `monkeypatch.setattr` targets internal functions, methods, or classes rather than external boundaries, the count is irrelevant -- redesign for testability instead.

For rules: see `rules.md`
For examples: see `examples.md`

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/libertininick) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-16 -->

