jeremylongshore/claude-code-plugins-plus-skills
unit-test-generator
plugins/testing/unit-test-generator/skills/generating-unit-tests/SKILL.md
January 22, 2026
Select agents to install to:
npx add-skill https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/main/plugins/testing/unit-test-generator/skills/generating-unit-tests/SKILL.md -a claude-code --skill generating-unit-testsInstallation paths:
.claude/skills/generating-unit-tests/# Unit Test Generator
This skill provides automated assistance for unit test generator tasks.
## Prerequisites
Before using this skill, ensure you have:
- Source code files requiring test coverage
- Testing framework installed (Jest, Mocha, pytest, JUnit, etc.)
- Understanding of code dependencies and external services to mock
- Test directory structure established (e.g., `tests/`, `__tests__/`, `spec/`)
- Package configuration updated with test scripts
## Instructions
### Step 1: Analyze Source Code
Examine code structure and identify test requirements:
1. Use Read tool to load source files from {baseDir}/src/
2. Identify all functions, classes, and methods requiring tests
3. Document function signatures, parameters, return types, and side effects
4. Note external dependencies requiring mocking or stubbing
### Step 2: Determine Testing Framework
Select appropriate testing framework based on language:
- JavaScript/TypeScript: Jest, Mocha, Jasmine, Vitest
- Python: pytest, unittest, nose2
- Java: JUnit 5, TestNG
- Go: testing package with testify assertions
- Ruby: RSpec, Minitest
### Step 3: Generate Test Cases
Create comprehensive test suite covering:
1. Happy path tests with valid inputs and expected outputs
2. Edge case tests with boundary values (empty arrays, null, zero, max values)
3. Error condition tests with invalid inputs
4. Mock external dependencies (databases, APIs, file systems)
5. Setup and teardown fixtures for test isolation
### Step 4: Write Test File
Generate test file in {baseDir}/tests/ with structure:
- Import statements for code under test and testing framework
- Mock declarations for external dependencies
- Describe/context blocks grouping related tests
- Individual test cases with arrange-act-assert pattern
- Cleanup logic in afterEach/tearDown hooks
## Output
The skill generates complete test files:
### Test File Structure
```javascript
// Example Jest test file
import { validator } from '../src/utils/validator';
describe('Valid