# Unit Test

> Unit testing techniques, mocking, and assertions

- Skill: `dongduong2001/unit-test` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dongduong2001/unit-test`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dongduong2001/unit-test/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: DongDuong2001 (https://skillmd.com/u/dongduong2001)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/dongduong2001/unit-test

---


# Unit Test Skill

This skill focuses on writing fast, isolated tests for individual units of code (functions, methods, classes).

## When to use this skill
- When writing tests for utility functions, algorithms, or standalone classes.
- When using tools like Jest, pytest, JUnit, or xUnit.
- When needing to mock out dependencies (databases, APIs, file systems).

## Guidelines
- **Isolation:** A unit test should not rely on an external database or network. Use mocks or stubs instead.
- **Naming:** Use clear, descriptive names (e.g., `calculateTotal_withValidInput_returnsCorrectSum`).
- **Structure:** Use the Arrange-Act-Assert (AAA) pattern.
- **Speed:** Unit tests must be fast so developers can run them frequently.

