본문으로 건너뛰기
Skillpedia
테스트29k · #9520

tdd-guide

하는 일

이 스킬은 실패하는 테스트를 쓰는 단계부터 안전하게 리팩터링하는 단계까지 테스트 주도 개발을 에이전트가 안내하게 합니다. 코드보다 먼저, 또는 코드와 함께 테스트를 두고 싶은 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓코드를 쓰기 전에 테스트를 먼저 작성하고 싶을 때.
  • ✓커버리지 보고서에 테스트가 필요한 빈틈이 보일 때.
  • ✓Jest, Pytest, JUnit, Vitest를 쓰는 프로젝트에 테스트 픽스처나 목이 필요할 때.

스킬 링크

https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/skills/tdd-guide/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/skills/tdd-guide/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“divide 함수에 대해 실패하는 테스트를 먼저 작성하고, 그다음 테스트가 통과하도록 도와주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 소스 코드에서 테스트 골격을 생성하고, 레드, 그린, 리팩터 단계를 거치는 TDD 작업 흐름을 실행합니다. 또한 커버리지 보고서를 읽어 빈틈을 찾으며, 80% 같은 커버리지 목표를 지향합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

TDD Guide

Test-driven development skill for generating tests, analyzing coverage, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, and Vitest.


Workflows

Generate Tests from Code

  1. Provide source code (TypeScript, JavaScript, Python, Java)
  2. Specify target framework (Jest, Pytest, JUnit, Vitest)
  3. Run test_generator.py with requirements
  4. Review generated test stubs
  5. Validation: Tests compile and cover happy path, error cases, edge cases

Analyze Coverage Gaps

  1. Generate coverage report from test runner (npm test -- --coverage)
  2. Run coverage_analyzer.py on LCOV/JSON/XML report
  3. Review prioritized gaps (P0/P1/P2)
  4. Generate missing tests for uncovered paths
  5. Validation: Coverage meets target threshold (typically 80%+)

TDD New Feature

  1. Write failing test first (RED)
  2. Run tdd_workflow.py --phase red to validate
  3. Implement minimal code to pass (GREEN)
  4. Run tdd_workflow.py --phase green to validate
  5. Refactor while keeping tests green (REFACTOR)
  6. Validation: All tests pass after each cycle

Examples

Test Generation — Input → Output (Pytest)

Input source function (math_utils.py):

def divide(a: float, b: float) -> float:
    if b == 0:
        raise ValueError("Cannot divide by zero")
    return a / b

Command:

python scripts/test_generator.py --input math_utils.py --framework pytest

Generated test output (test_math_utils.py):

import pytest
from math_utils import divide

class TestDivide:
    def test_divide_positive_numbers(self):
        assert divide(10, 2) == 5.0

    def test_divide_negative_numerator(self):
        assert divide(-10, 2) == -5.0

    def test_divide_float_result(self):
        assert divide(1, 3) == pytest.approx(0.333, rel=1e-3)

    def test_divide_by_zero_raises_value_error(self):
        with pytest.raises(ValueError, match="Cannot divide by zero"):
            divide(10, 0)

    def test_divide_zero_numerator(self):
        assert divide(0, 5) == 0.0

Coverage Analysis — Sample P0/P1/P2 Output

Command:

python scripts/coverage_analyzer.py --report lcov.info --threshold 80

Sample output:

Coverage Report — Overall: 63% (threshold: 80%)

P0 — Critical gaps (uncovered error paths):
  auth/login.py:42-58   handle_expired_token()       0% covered
  payments/process.py:91-110  handle_payment_failure()   0% covered

P1 — High-value gaps (core logic branches):
  users/service.py:77   update_profile() — else branch  0% covered
  orders/cart.py:134    apply_discount() — zero-qty guard  0% covered

P2 — Low-risk gaps (utility / helper functions):
  utils/formatting.py:12  format_currency()            0% covered

Recommended: Generate tests for P0 items first to reach 80% threshold.

Key Tools

Tool Purpose Usage
test_generator.py Generate test cases from code/requirements python scripts/test_generator.py --input source.py --framework pytest
coverage_analyzer.py Parse and analyze coverage reports python scripts/coverage_analyzer.py --report lcov.info --threshold 80
tdd_workflow.py Guide red-green-refactor cycles python scripts/tdd_workflow.py --phase red --test test_auth.py
fixture_generator.py Generate test data and mocks python scripts/fixture_generator.py --entity User --count 5

Additional scripts: framework_adapter.py (convert between frameworks), metrics_calculator.py (quality metrics), format_detector.py (detect language/framework), output_formatter.py (CLI/desktop/CI output).


Input Requirements

For Test Generation:

  • Source code (file path or pasted content)
  • Target framework (Jest, Pytest, JUnit, Vitest)
  • Coverage scope (unit, integration, edge cases)

For Coverage Analysis:

  • Coverage report file (LCOV, JSON, or XML format)
  • Optional: Source code for context
  • Optional: Target threshold percentage

For TDD Workflow:

  • Feature requirements or user story
  • Current phase (RED, GREEN, REFACTOR)
  • Test code and implementation status

Spec-First Workflow

TDD is most effective when driven by a written spec. The flow:

  1. Write or receive a spec — stored in specs/<feature>.md
  2. Extract acceptance criteria — each criterion becomes one or more test cases
  3. Write failing tests (RED) — one test per acceptance criterion
  4. Implement minimal code (GREEN) — satisfy
자주 묻는 질문

red-green-refactor란 무엇인가요?

실패하는 테스트를 쓰고, 가장 단순한 코드로 통과시킨 뒤, 테스트가 계속 통과하는 상태에서 코드를 정리하는 것입니다.

어떤 언어의 테스트를 생성하나요?

이 스킬은 TypeScript, JavaScript, Python, Java 소스 코드를 언급합니다.

테스트를 자동으로 생성하나요?

네. 테스트 생성기가 골격을 만들고, 여러분이 검토하고 완성합니다.

상세 정보

작성자의 원본 설명

Use when writing tests first, generating tests, fixtures or mocks, or closing coverage gaps in Jest, Pytest, JUnit, Vitest or Mocha. Drives red-green-refactor with tdd_workflow.py, generates tests with test_generator.py and reads coverage with coverage_analyzer.py.

repo: alirezarezvani/claude-skills

인기도

GitHub 스타
29k
순위
#9520
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬