# Test Writer

> How to write pytest tests for modules in this workspace. Load whenever you are about to write or extend tests.

- Skill: `firebase/test-writer` (Agent Skill)
- Install (CLI): `npx skillmds@latest add firebase/test-writer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/firebase/test-writer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: firebase (https://skillmd.com/u/firebase)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/firebase/test-writer

---


# Test writer

When writing pytest tests in this workspace:

- **One test file per module.** `foo.py` lives next to `foo_test.py` (suffix, not prefix).
- **Cover the happy path AND at least one edge case.** Empty input, duplicates, boundary values — pick what matters for the unit under test.
- **Use `pytest.mark.parametrize`** when the same assertion runs over a small table of inputs. Keep IDs descriptive.
- **Name tests `test_<unit>_<scenario>_<expected>`.** Examples: `test_total_empty_cart_returns_zero`, `test_add_duplicate_item_merges_quantities`.
- **Arrange / Act / Assert.** Three clear blocks. No setup hidden in fixtures unless it's reused across at least two tests.
- **Assert behavior, not implementation.** Don't reach into private attributes or count function calls; check the observable result.
- **Imports at module top.** Don't import inside test functions.

