andresharpe/dotbot/write-unit-tests
Claude Code and agent skill by andresharpe/dotbot
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install andresharpe/dotbot/write-unit-testsSKILL.md
Write Unit Tests
Guide for writing effective unit tests that verify behavior and catch regressions.
When to Use
- Testing pure logic and business rules
- Verifying individual components in isolation
- Testing edge cases and error conditions
- TDD red-green-refactor cycle
Test Structure (Arrange-Act-Assert)
Test Naming
Use descriptive names that explain what's being tested:
MethodName_Scenario_ExpectedBehaviorMethodName_WhenCondition_ShouldDoSomethingMethodName_GivenInput_ReturnsExpectedOutput
Examples:
Calculate_WithNegativeNumber_ThrowsArgumentExceptionProcessOrder_WhenInventoryInsufficient_ReturnsFailureResultFormatDate_GivenNull_ReturnsEmptyString
Test Coverage
1. Happy Path
- Normal, expected inputs
- Successful execution
- Expected outputs
2. Edge Cases
- Boundary values (min, max, zero, empty)
- Null inputs
- Empty collections
- Special characters
3. Error Scenarios
- Invalid inputs
- Exceptions
- Validation failures
- Constraint violations
Mocking & Isolation
- Use test doubles for dependencies
- Mock external services, databases, APIs
- Keep tests fast and deterministic
- Don't mock what you don't own (value objects, DTOs)
Assertions
Use fluent assertions for clarity:
Best Practices
- One assertion per test - Test one thing at a time
- Fast execution - No I/O, no sleeps, no real dependencies
- Deterministic - Same inputs always produce same results
- Independent - Tests don't depend on each other
- Readable - Clear setup, action, and verification
- Maintainable - Easy to update when requirements change
Common Patterns
Testing Exceptions
Testing Async Methods
Theory Tests (Multiple Inputs)
Common Pitfalls
- ❌ Testing implementation details
- ❌ Tests that depend on execution order
- ❌ Flaky tests (random, time-dependent)
- ❌ Testing too much in one test
- ❌ Not testing error cases
- ❌ Using real dependencies (databases, files, network)
Test Organization
Checklist
- [ ] Test name clearly describes what's being tested
- [ ] Arrange-Act-Assert structure
- [ ] Happy path covered
- [ ] Edge cases covered
- [ ] Error scenarios covered
- [ ] Dependencies are mocked
- [ ] Assertions are clear and specific
- [ ] Test is fast (< 100ms)
- [ ] Test is independent of others
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcontent/skills/write-unit-tests/SKILL.md
Popularity
- Repository stars
- 50
- Repository forks
- 24
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 5 Oct 2026, a month ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/andresharpe/dotbot/write-unit-tests)