From workflow-bundle
Use when: (1) "테스트 검증해줘", (2) "테스트 실행하고 고쳐줘", (3) "test heal", (4) after test-generator creates tests, (5) tests are failing and need fixing.
npx claudepluginhub onejaejae/skillsThis skill uses the workspace's default tool permissions.
Review, execute, and repair test code to ensure quality and all tests pass.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Review, execute, and repair test code to ensure quality and all tests pass.
테스트 품질 보증 전문가로서:
이 스킬은 특정 feature의 테스트 파일을 대상으로 합니다.
research_favorite)tests/services/test_research_favorite_service.py)tests/controllers/test_{feature}_controller.py
tests/services/test_{feature}_service.py
tests/repositories/test_{feature}_repository.py
tests/conftest.py - 전역 fixture 정의tests/utils/helpers.py - assert_success_response, assert_error_responsetests/factories/ - Factory 클래스들tests/CLAUDE.md - 프로젝트 테스트 컨벤션테스트 실행 전 반드시 확인:
export ENV=test # 필수! 없으면 bootstrap.py에서 sys.exit(1) 발생
┌─────────────────┐
│ 1. Review │ 테스트 코드 품질 검토
└────────┬────────┘
▼
┌─────────────────┐
│ 2. Execute │ ENV=test pytest 실행
└────────┬────────┘
▼
┌────┴────┐
│ Pass? │
└────┬────┘
Yes │ No
▼ ▼
┌──────┐ ┌─────────────────┐
│ Done │ │ 3. Analyze │ 실패 원인 분석
└──────┘ └────────┬────────┘
▼
┌───────────────────┐
│ Test code issue? │
└────────┬──────────┘
Yes │ No
▼ ▼
┌─────────────┐ ┌─────────────────┐
│ 4. Repair │ │ Report impl bug │
└──────┬──────┘ └─────────────────┘
│
└──────► (pytest 재실행, 최대 3회)
테스트 코드 품질 검토 체크리스트:
test_{method}_{case})수정 전에 동일 layer의 기존 통과 테스트를 먼저 읽어서 프로젝트 패턴 파악:
# 같은 layer의 다른 테스트 파일 참조
tests/controllers/test_research_favorite_controller.py
tests/services/test_research_favorite_service.py
# 반드시 ENV=test 포함
ENV=test pytest tests/{layer}/test_{feature}_{layer}.py -v
# 실패한 테스트만 재실행
ENV=test pytest tests/{layer}/test_{feature}_{layer}.py -v --ff
# 첫 번째 실패에서 중단
ENV=test pytest tests/{layer}/test_{feature}_{layer}.py -v -x
실패 원인 분류:
@pytest.mark.asyncio 누락 등)1. Factory 메서드 혼동 (Model vs Schema)
# WRONG: Controller 테스트에서 Model 반환
mock_service.get.return_value = ResearchDesignFactory.build() # SQLAlchemy Model
# CORRECT: Controller 테스트는 Response 스키마 필요
mock_service.get.return_value = ResearchDesignFactory.build_response() # Pydantic Schema
2. mock_services fixture 추출 누락
# WRONG: fixture 미정의 상태에서 사용 시 "fixture not found" 에러
def test_get(self, mock_research_design_service): # fixture가 없음!
# CORRECT: mock_services에서 추출하는 fixture 정의
@pytest.fixture
def mock_research_design_service(self, mock_services):
return mock_services["research_design_service"]
3. model_validate에 MagicMock 사용
# WRONG: Service가 model_validate 사용 시 MagicMock은 실패
mock_repo.get.return_value = MagicMock(spec=ResearchDesign)
# CORRECT: 실제 Model 인스턴스 사용
mock_repo.get.return_value = ResearchDesignFactory.build(id=1)
4. assert_success_response datetime 직렬화
# WRONG: model_dump 없이 list 비교 시 datetime 직렬화 불일치
assert_success_response(response=response, expected_data=mock_items)
# CORRECT: model_dump(mode="json")으로 datetime을 ISO string으로 변환
assert_success_response(
response=response,
expected_data=[item.model_dump(mode="json") for item in mock_items],
)
5. PATCH partial update None 전파 실패
# WRONG: Factory 기본값이 None을 덮어씀
mock_updated = ResearchDesignFactory.build() # cohorts에 기본값 들어감
# call_kwargs["cohorts"] is None → FAIL (Factory 기본값이 들어있음)
# CORRECT: 서비스 파라미터 기본값이 None이므로 call_args로 검증
call_kwargs = mock_repo.update.call_args.kwargs
assert call_kwargs["cohorts"] is None # 미전달 필드는 None
6. Async 데코레이터 추가
# Before
async def test_create_success(self, ...):
# After
@pytest.mark.asyncio
async def test_create_success(self, ...):
7. Exception type 수정
# Before - 범용 Exception
with pytest.raises(Exception):
# After - 구체적인 Exception
with pytest.raises(ResearchDesignNotFoundException):
## Test Heal Report: {Feature}
### Review Summary
- Convention 준수: OK / (issues)
- 커버리지: OK / (missing cases)
- Mock 설정: OK / (issues)
### Execution Result
- Total: {n} tests
- Passed: {n}
- Failed: {n}
### Failures Analysis
| Test | Error Type | Root Cause | Action |
|------|------------|------------|--------|
| test_xxx | AssertionError | Factory build() 대신 build_response() 필요 | 수정함 |
| test_yyy | FixtureError | mock_services 추출 fixture 누락 | 수정함 |
### Repairs Made
1. `test_create_success`: Factory.build() → Factory.build_response()
2. `test_get_not_found`: mock_services 추출 fixture 추가
### Implementation Issues (보고)
1. `ResearchService.create`: 반환 타입이 None이 아님 - 확인 필요
### Final Status
All tests passing / {n} tests still failing (구현 코드 수정 필요)