Agent skill
testing-patterns
Write effective tests with proper structure and coverage. Use when writing unit tests, integration tests, or improving test quality.
Install this agent skill to your Project
npx add-skill https://github.com/neokn/dotClaude/tree/main/skills/testing-patterns
SKILL.md
Testing Patterns Skill
Help write clear, maintainable, effective tests.
Test Structure (AAA Pattern)
// Arrange - Set up test data and conditions
// Act - Execute the code under test
// Assert - Verify the expected outcome
Naming Convention
test_[unit]_[scenario]_[expected result]
Examples:
- test_calculateTotal_withEmptyCart_returnsZero
- test_login_withInvalidPassword_throwsAuthError
- test_fetchUser_whenNotFound_returns404
What to Test
Unit Tests
- Pure functions and calculations
- Business logic
- Edge cases and boundaries
- Error conditions
Integration Tests
- API endpoints
- Database operations
- External service interactions
- Authentication flows
Do NOT Test
- Framework/library internals
- Private methods directly
- Trivial getters/setters
- Third-party code
Test Quality Checklist
- Tests one thing only
- Clear test name describes behavior
- Independent (no test order dependency)
- Fast (mock external dependencies)
- Deterministic (no flaky tests)
- Readable (future you is the audience)
Mocking Guidelines
Mock:
- External APIs
- Database (for unit tests)
- Time/dates
- Random values
- File system (when appropriate)
Don't mock:
- The thing you're testing
- Simple value objects
- Everything (leads to brittle tests)
Coverage Strategy
Focus on:
- Critical business logic: 90%+
- Happy paths: 100%
- Error paths: 80%+
- Edge cases: Case by case
Avoid:
- Chasing 100% blindly
- Testing implementation details
- Duplicate coverage
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
api-design
Design RESTful APIs with best practices. Use when creating new endpoints, designing API contracts, or reviewing API structures.
git-guardrails-claude-code
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
setup-pre-commit
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
obsidian-vault
Search, create, and manage notes in the Obsidian vault with wikilinks and index notes. Use when user wants to find, create, or organize notes in Obsidian.
edit-article
Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.
scaffold-exercises
Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
Didn't find tool you were looking for?