MCP HubMCP Hub
返回技能列表

tdd-test-generation

thkt
更新于 Today
9 次查看
3
3
在 GitHub 上查看
testingdesign

关于

This Claude Skill provides comprehensive TDD guidance using the RGRC cycle and Baby Steps methodology. It offers systematic test design techniques including equivalence partitioning, boundary value analysis, and decision tables for generating test cases. Use it when implementing TDD workflows, discussing test generation strategies, or building test-generator agents.

技能文档

TDD Test Generation - Comprehensive Test-Driven Development Guide

Overview

This skill provides systematic guidance for Test-Driven Development (TDD) combining:

  1. RGRC Cycle - Red-Green-Refactor-Commit workflow inspired by t_wada
  2. Baby Steps - Incremental development with 2-minute cycles
  3. Systematic Test Design - Equivalence partitioning, boundary value analysis, decision tables
  4. Test Generation - From SOW test plans to executable test cases

When to Use This Skill

Automatic Triggers

Keywords that activate this skill:

  • TDD, Test-Driven Development, テスト駆動開発
  • RGRC, Red-Green-Refactor, Baby Steps
  • Test generation, test design, test cases
  • Equivalence partitioning, boundary value, decision table
  • Coverage, test first, unit test

Explicit Invocation

For guaranteed activation:

  • "Apply TDD skill"
  • "Use TDD test generation skill"
  • "Follow RGRC cycle"

Common Scenarios

  • Implementing features with /code command
  • Generating tests with test-generator agent
  • Planning test coverage strategies
  • Refactoring with test safety nets
  • Reviewing test design quality

Core Concepts

1. Baby Steps - The Foundation

"Make the smallest possible change at each step" - t_wada

Why it matters:

  • Immediate error localization (bug is in last 2-minute change)
  • Continuous working state (always seconds from green)
  • Rapid feedback loop
  • Confidence through small successes

2-Minute Cycle:

  1. Write smallest failing test (30s)
  2. Make it pass minimally (1min)
  3. Run tests (10s)
  4. Tiny refactor (30s)
  5. Commit if green (20s)

2. RGRC Cycle

Goal: "Clean code that works" (動作するきれいなコード) - Ron Jeffries

Red Phase

Write failing test → Verify correct failure reason

Green Phase

Minimal code to pass → "You can sin" (quick/dirty OK)

Refactor Phase

Apply SOLID/DRY → Improve structure → Keep tests green

Commit Phase

All checks pass → Save stable state

3. Systematic Test Design

Quality > Quantity - Fewer well-designed tests catch more bugs

Equivalence Partitioning

Group inputs with same behavior, test one from each:

// Age validation: <18 (invalid), 18-120 (valid), >120 (invalid)
test('partition 1: rejects 17', () => ...)
test('partition 2: accepts 30', () => ...)
test('partition 3: rejects 121', () => ...)

Boundary Value Analysis

Test edges [min-1, min, max, max+1]:

test('boundary: rejects 17 (18-1)', () => ...)
test('boundary: accepts 18 (min)', () => ...)
test('boundary: accepts 120 (max)', () => ...)
test('boundary: rejects 121 (120+1)', () => ...)

Decision Table Testing

Complex logic with multiple conditions:

// isLoggedIn × isPremium × isActive → canAccess
// Use decision table to cover all combinations systematically

Detailed Knowledge Base

Reference Documents

  • [@./references/tdd-rgrc.md] - Complete RGRC cycle guide with t_wada's methodology
  • [@./references/test-design.md] - Systematic test design techniques, coverage goals (C0: 80%, C1: 70%), framework-agnostic patterns

Integration Points

With Agents

  • test-generator - Generates tests from SOW using this skill's principles
  • testability-reviewer - Evaluates test design quality

With Commands

  • /code - Applies TDD during implementation
  • /test - Validates coverage and quality

Integration Method

# In agent YAML frontmatter
dependencies: [tdd-test-generation]

Or explicit reference:

[@~/.claude/skills/tdd-test-generation/SKILL.md]

Quick Start

New Feature

  1. Red - Write failing test
  2. Green - Minimal code
  3. Refactor - Clean up
  4. Commit - Save
  5. Repeat

From SOW

  1. Read SOW test plan
  2. Apply equivalence partitioning
  3. Add boundary values
  4. Generate test cases
  5. Verify coverage

Refactoring

  1. Ensure comprehensive tests
  2. Verify green
  3. Refactor incrementally
  4. Run frequently
  5. Commit when green

Best Practices

Do's ✅

  • Write test before code
  • Keep steps small (Baby Steps)
  • Run tests frequently
  • Commit when green
  • Use systematic test design
  • Apply SOLID/DRY in Refactor, not before

Don'ts ❌

  • Skip Red phase
  • Write multiple tests before any pass
  • Refactor without green tests
  • Commit with failing tests
  • Random test selection
  • Complex architecture in Green phase

Coverage Goals

Industry-recommended targets:

  • C0 (Statement): 80% minimum
  • C1 (Branch): 70% minimum

Why: Cost-benefit balance, focus on critical paths

When NOT to Use TDD

Skip for:

  • Prototypes (throwaway code)
  • External API integration (use mocks)
  • Simple one-off scripts
  • UI experiments (visual iteration first)

Success Metrics

TDD is working when:

  • Tests written before code (100%)
  • Cycles complete in <5 min
  • Refactoring feels safe
  • Coverage meets targets
  • Velocity increases over time

Resources

references/

Comprehensive documentation loaded as needed:

  • tdd-rgrc.md - Detailed RGRC cycle implementation
  • test-design.md - Complete test design techniques guide

scripts/

Currently empty - no automation scripts needed (knowledge-only skill)

assets/

Currently empty - no template files needed (knowledge-only skill)

快速安装

/plugin add https://github.com/thkt/claude-config/tree/main/tdd-test-generation

在 Claude Code 中复制并粘贴此命令以安装该技能

GitHub 仓库

thkt/claude-config
路径: skills/tdd-test-generation

相关推荐技能

evaluating-llms-harness

测试

该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。

查看技能

langchain

LangChain是一个用于构建LLM应用程序的框架,支持智能体、链和RAG应用开发。它提供多模型提供商支持、500+工具集成、记忆管理和向量检索等核心功能。开发者可用它快速构建聊天机器人、问答系统和自主代理,适用于从原型验证到生产部署的全流程。

查看技能

go-test

go-test Skill为Go开发者提供全面的测试指导,涵盖单元测试、性能基准测试和集成测试的最佳实践。它能帮助您正确实现表驱动测试、子测试组织、mock接口和竞态检测,同时指导测试覆盖率分析和性能基准测试。当您编写_test.go文件、设计测试用例或优化测试策略时,这个Skill能确保您遵循Go语言的标准测试惯例。

查看技能

project-structure

这个Skill为开发者提供全面的项目目录结构设计指南和最佳实践。它涵盖了多种项目类型包括monorepo、前后端框架、库和扩展的标准组织结构。帮助团队创建可扩展、易维护的代码架构,特别适用于新项目设计、遗留项目迁移和团队规范制定。

查看技能