test-driven-developer
Write bulletproof code using Test-Driven Development (TDD) with proper unit tests, integration tests, mocking, and test architecture. Use when implementing features test-first or improving test coverage.
- License 许可
- CC0-1.0
- 最近更新
- 2026-05-06
- Stars
- ★ 14
- Forks
- 1
01 前言 Front Matter
- name
- test-driven-developer
- license
- CC0-1.0
- metadata
- { "tools": "cursor, windsurf, copilot, claude-code", "author": "skillsdirectory", "version": "1.0", "category": "coding" }
- description
- Write bulletproof code using Test-Driven Development (TDD) with proper unit tests, integration tests, mocking, and test architecture. Use when implementing features test-first or improving test coverage.
- compatibility
- Works with Cursor, Windsurf, GitHub Copilot, Claude Code, and any AI coding assistant
03 SKILL.md 正文
Test-Driven Developer
You write tests first, then code. Every feature starts with a failing test.
TDD Cycle (Red-Green-Refactor)
1. ? RED → Write a failing test
2. ? GREEN → Write minimal code to pass
3. ? REFACTOR → Clean up without breaking tests
4. ↩️ REPEAT
Test Types
Unit Tests (Fast, Isolated)
// Test ONE function/method in isolation
describe('calculateDiscount', () => {
it('should apply 10% discount for orders over $100', () => {
expect(calculateDiscount(150)).toBe(15)
})
it('should return 0 for orders under $100', () => {
expect(calculateDiscount(50)).toBe(0)
})
it('should throw for negative amounts', () => {
expect(() => calculateDiscount(-10)).toThrow('Invalid amount')
})
})
Integration Tests (Components Working Together)
describe('POST /api/users', () => {
it('should create user and return 201', async () => {
const response = await request(app)
.post('/api/users')
.send({ name: 'John', email: 'john@example.com' })
expect(response.status).toBe(201)
expect(response.body.data.name).toBe('John')
})
})
E2E Tests (Full User Flows)
test('user can sign up and see dashboard', async ({ page }) => {
await page.goto('/signup')
await page.fill('[name=email]', 'test@example.com')
await page.fill('[name=password]', 'SecurePass123!')
await page.click('button[type=submit]')
await expect(page).toHaveURL('/dashboard')
})
Testing Patterns
AAA Pattern
Arrange → Set up test data and conditions
Act → Execute the code being tested
Assert → Verify the expected outcome
Test Naming Convention
it('should [expected behavior] when [condition]')
What to Test
- ✅ Happy path (expected inputs)
- ✅ Edge cases (empty, null, max values)
- ✅ Error cases (invalid inputs, failures)
- ✅ Boundary conditions (limits, thresholds)
What NOT to Test
- ❌ Third-party libraries (trust them)
- ❌ Implementation details (test behavior)
- ❌ Trivial getters/setters
- ❌ Framework internals
Mocking
// Mock external dependency
const mockEmailService = {
send: jest.fn().mockResolvedValue({ success: true })
}
// Inject mock
const userService = new UserService(mockEmailService)
// Verify interaction
expect(mockEmailService.send).toHaveBeenCalledWith(
'user@example.com',
expect.stringContaining('Welcome')
)
04 同仓库更多 Skills
write-contracts
Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.
web-search
通用网络搜索技能,支持多引擎搜索(百度、必应、DuckDuckGo),无需API密钥即可获取实时信息
solo-build
Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says "build it", "start building", "execute plan", "implement tasks", "ship it", or references a track ID. Do NOT use for planning (use /plan) or scaffolding (use /scaffold).
react-email
Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.
APITester Agent-Driven API Testing
Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.
hubspot-implementation-plan
Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running /hubspot-audit.