# Write Unit Tests

> Enable an agent to write unit tests Use when this capability is needed.

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

---


# Write unit tests

## Best practices

- Unit tests should go into tests named for the functions being tested.
  - If you have a function `Foo`, you should have a test function named
    `TestFoo`.
  - Methods with receivers should include the name of the receiver's type. A
    method like `func (f *Foo) Bar() {...}` should have a test named
    `TestFooBar`.
- Tests should only test the behavior of the function. Don't exhaustively test
  every possible input.
- Each behavior you test should have a test case. If you have more than two
  test cases, use table-driven tests.

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

