unit-test-advisor
Domain unit test patterns: test structure, mocking strategies, test data builders, Given-When-Then.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Domain unit test patterns: test structure, mocking strategies, test data builders, Given-When-Then.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when creating an SDD implementation plan from exploration.md, with deep interview, task breakdown, and batch assignments.
Generate a Product Requirements Document via interactive interview. Writes a markdown PRD that captures intent, user stories, and out-of-scope. Use when the brief is vague, when no ticket is bound, or when SDD invokes it from its PRD gate.
Use when executing an SDD plan via batch-based task implementation, tracking progress with [ ]/[X] markers and quality gates.
Use when starting an SDD workflow to discover codebase context, curate relevant files, and prepare exploration.md for planning.
SDD Orchestrator coordinates SDD (Spec-Driven Development) workflow via sub-agents
Use when reviewing code changes before commit, comparing implementation against SDD plan, or doing standalone code review with advisor consultation.
| name | unit-test-advisor |
| scope | ["testing"] |
| description | Domain unit test patterns: test structure, mocking strategies, test data builders, Given-When-Then. |
| allowed-tools | ["Read","Grep","Glob"] |
| model | sonnet |
Provide expert guidance on writing effective unit tests for domain logic following Given-When-Then structure.
Invoke this skill when the user:
Every test method must follow the 3A (Arrange, Act, Assert) pattern with clear comment separators:
// Given
<set up test data and mock behaviors>
// When
<invoke the method under test — single line>
// Then
<assert results and verify mock interactions>
Pattern: should<ExpectedBehavior>When<Condition>
| Good | Bad |
|---|---|
shouldReturnUserWhenValidIdProvided | test1, testFind |
shouldThrowExceptionWhenValidationFails | whenUserPresent |
shouldReturnEmptyWhenEntityNotFound | testMethodName_1 |
Use the Object Mother (or factory function) pattern for reusable test data:
// Java/Mother
User user = UserMother.aValidUser();
User admin = UserMother.aValidUser().withRole(ADMIN).build();
// TypeScript/Factory
const user = createUser({ role: 'admin' });
Never construct domain objects inline when the same construction is reused across tests.
| Mock | Do NOT Mock |
|---|---|
| External repositories | Value objects |
| External API clients | Domain entities |
| Domain services (cross-aggregate) | DTOs |
| Infrastructure adapters | Simple utility functions |
Use BDD-style mocking when available:
given(repo.findById(id)).willReturn(Optional.of(entity));
then(repo).should().findById(id);
then(repo).should(never()).save(any());
Every test class should cover:
any() matchers when a specific value can be used.assertTrue(result != null) — use assertThat(result).isNotNull().Before finalizing your review, check gotchas.md for common Claude mistakes in this domain.
This skill supports advisor mode: when invoked by the SDD orchestrator with a GUIDANCE CONTEXT FROM PLANNER block in the prompt, use the following procedure instead of the standard interactive review flow.
Advisor mode is active when the prompt contains:
GUIDANCE CONTEXT FROM PLANNER: blockCURRENT PLAN EXCERPT: blockGUIDANCE CONTEXT FROM PLANNER block to understand what the planner needs reviewed.CURRENT PLAN EXCERPT to see the specific tasks and design decisions.Focus ONLY on your specialist domain: Test structure, mocking strategies, Mother pattern, Given-When-Then.
### Strengths
- [What looks sound in the plan from this skill's domain perspective]
### Issues Found
[Severity: Critical / Major / Minor — reference specific task IDs or section names]
- T001: [issue description]
### Recommendations
[Specific, actionable. Reference task ID or section name for each recommendation.]
- T001: [recommendation]
Save full advice output to engram:
mem_save(
title: "sdd/{change-name}/guidance/unit-test-advisor",
type: "architecture",
project: "{project-name}",
content: "{your full structured advice output}"
)
If engram is unavailable, skip silently.
Return a concise summary (3-5 bullet points) plus the engram observation ID:
### Summary
- [key point 1]
- [key point 2]
- ...
### Engram ID
{observation_id or "unavailable"}
Do NOT return an SDD Envelope when in advisor mode.