generating-tdd-tests
TDD with RGRC cycle and Baby Steps methodology. Triggers: TDD, テスト駆動開発, Red-Green-Refactor, Baby Steps, test generation, テスト生成, テスト設計, テストケース, boundary value, 境界値分析, coverage, カバレッジ, unit test
When & Why to Use This Skill
This Claude skill automates the Test-Driven Development (TDD) workflow by strictly adhering to the Red-Green-Refactor-Commit (RGRC) cycle and the 'Baby Steps' methodology. It empowers developers to generate high-quality unit tests, optimize code coverage (C0/C1), and apply advanced test design techniques like boundary value analysis and equivalence partitioning across popular frameworks such as Vitest, Jest, and Bun.
Use Cases
- Feature Development with RGRC: Streamline the implementation of new features by following a disciplined cycle of writing failing tests, implementing minimal code to pass, and refactoring.
- Robust Test Design: Generate comprehensive test cases for complex logic using boundary value analysis and decision tables to ensure all edge cases and logical branches are covered.
- Incremental Refactoring: Use the 'Baby Steps' methodology to perform low-risk, frequent code improvements, ensuring the system remains stable and tests stay green throughout the process.
- Coverage Gap Analysis: Automatically identify and create missing tests to reach specific coverage targets (e.g., 90% C0 or 80% C1) for existing or new codebases.
- Framework-Specific Test Generation: Quickly set up standardized test suites tailored to the project's specific environment, whether it's Vitest, Jest, or Bun.
| name | generating-tdd-tests |
|---|---|
| description | > |
| allowed-tools | [Read, Write, Edit, Grep, Glob, Task] |
| context | fork |
| user-invocable | false |
TDD Test Generation
RGRC Cycle
| Phase | Goal | Rule |
|---|---|---|
| Red | Failing test | Verify failure reason |
| Green | Pass test | "You can sin" - dirty OK |
| Refactor | Clean code | Keep tests green |
| Commit | Save state | All checks pass |
Baby Steps (2-min cycle)
30s: Write failing test → 1min: Make pass → 10s: Run tests → 30s: Tiny refactor → 20s: Commit if green
Test Design
| Technique | Use For | Example |
|---|---|---|
| Equivalence Partitioning | Group same behavior | Age: <18, 18-120 |
| Boundary Value | Test edges | 17, 18, 120, 121 |
| Decision Table | Multi-condition logic | isLoggedIn × isPremium |
Coverage
| Level | Target | Focus |
|---|---|---|
| C0 | 90% | All lines executed |
| C1 | 80% | All branches taken |
Naming
| Level | Pattern |
|---|---|
| Suite | describe("[Target]", ...) |
| Group | describe("[Method]", ...) |
| Test | it("when [condition], should [expected]", ...) |
Framework Detection
| Condition | Framework |
|---|---|
vitest in deps |
Vitest |
jest in deps |
Jest |
bun as runtime |
Bun test |
| No framework found | Vitest |
References
| Topic | File |
|---|---|
| Feature-driven | references/feature-driven.md |
| Bug-driven | references/bug-driven.md |
| Flaky tests | references/flaky-test-management.md |