Skip to main content

fixture-driven-tdd

Fixture-driven TDD workflow for CLI parsers and session tests. Uses real CLI JSON from DB/capture, FakeClaude segments, and .jsonl fixtures. Use when developing parsers, adding event types, or writing server pipeline tests.

설치로 이동

소스 정보

저장소
recca0120/code-quest
최근 소스 활동
2026년 5월 7일 14:06
감지된 SKILL.md 언어
영어
스타
11
포크
2

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
fixture-driven-tdd
description
Fixture-driven TDD workflow for CLI parsers and session tests. Uses real CLI JSON from DB/capture, FakeClaude segments, and .jsonl fixtures. Use when developing parsers, adding event types, or writing server pipeline tests.
# Fixture-Driven TDD ## Principle > Test data must come from real CLI output, never guessed. Use DB exports or `capture-fixture.sh`. ## Fixture Locations ``` apps/summoner/src/__fixtures__/claude/ ├── real/ # 40+ files — DB exports & real CLI recordings └── synthetic/ # 18 files — hand-crafted for untriggerable events ``` Fixtures are auto-loaded by TEMPLATES in `apps/summoner/src/test/fake-claude.ts`. ## Workflow ### 1. Collect fixture ```bash # Real CLI capture scripts/capture-fixture.sh <name> [prompt] # Or from DB mysql -u root -h 127.0.0.1 -P 3306 code_quest -N -e \ "SELECT raw FROM raw_entries WHERE raw LIKE '{\"type\":\"<event_type>\"%' LIMIT 1;" ``` DB connection in `apps/server/.env` → `DATABASE_URL`. ### 2. Add to fixtures Save to `apps/summoner/src/__fixtures__/claude/real/<name>.jsonl` (or `synthetic/` if hand-crafted). ### 3. Add segment builder In `apps/summoner/src/test/fake-claude.ts`, add to `segments` object: ```typescript myEvent(param: string): string { const line = JSON.parse(TEMPLATES.MY_EVENT); line.some_field = param; line.uuid = `fake-my-event-${++_seq}`; return JSON.stringify(line); } ``` ### 4. Write test (RED) ```typescript import { segments as s } from '@code-quest/summoner/test'; // Parser test const parsed = adapter.parseLine(s.myEvent('test')); expect(parsed.status).toBe('ok'); // Pipeline test const claude = createFakeSummoner().claude(); const channelId = await claude.initialize(s.init('sess')); await claude.emit(s.myEvent('test')); expect(claude.received('message:my_event')).toHaveLength(1); ``` ### 5. Implement (GREEN) → Refactor ## Anti-patterns - Never hand-write JSON that pretends to be CLI output - Never use `inline JSON` in tests — use `segments.*()` builders - Synthetic fixtures must be clearly marked and tracked for replacement ## Reference - Capture script: `scripts/capture-fixture.sh` - Tracking: `docs/fixture-capture-tracking.md` - Segment builders: `apps/summoner/src/test/fake-claude.ts` (60+ builders)
GitHub에서 보기