skills/test-designing-guide/SKILL.md
Provides test design methodology for Unity projects. Use this skill whenever designing test cases from requirements or specifications, including selecting test techniques, deriving test cases, and formatting them. Even for small features, load this skill to ensure test design rigor.
npx skillsauth add nowsprinting/claude-code-settings-for-unity test-designing-guideInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide for designing test cases for Unity projects.
This skill requires the following inputs in its prompt:
| Input | Required | Description | |---------------------------|----------|------------------------------------------------------------------------------------------------------| | Requirements | Required | The feature requirements to test against | | Implementation design | Required | Class names, public method signatures, dependency interfaces, and design rationale | | Existing code context | Optional | File paths and class summaries of relevant existing code |
Silently ignore the following if present in the prompt:
Read the requirements and identify testable specifications. If the specifications are unclear, use the AskUserQuestion tool to request clarification before proceeding. If the test target has low testability, flag it in the Testability Assessment (Section 7).
For each test target, determine which layer it belongs to based on its nature and integration level:
/Editor/), asset file validation, and cross-asset consistency checks.AddComponent<T>(), a prefab, or a scene. Unit tests cover targets whose execution is initiated by a direct method call; integration tests cover behavior that only emerges from Unity's component wiring.
Note: Never use Edit Mode tests for runtime code logic. Edit Mode and Play Mode test runners cannot execute simultaneously — splitting coverage for a single SUT between the two modes prevents running all tests at once. Play Mode tests can run on actual devices (player builds), which Editor tests cannot.
Prefer specification-based tests over structural (implementation-coupled) tests. Structural tests break under refactoring and lose value fast. It's fine to write a structural test temporarily when you're unsure about an implementation, but plan to delete it once specification tests cover the same behavior.
For each test target, select appropriate techniques:
AskUserQuestion tool to confirm the expected behavior before deriving test cases. Do not guess or invent the behavior.AskUserQuestion to confirm with the user before designing test cases.When the SUT consumes a pseudo-random number generator (UnityEngine.Random, System.Random, etc.), choose one of these strategies based on what the spec actually pins down:
And/Range constraints, or Within/custom comparer for tolerances. Combine with Repeat attribute so flakiness isn't masked by a single lucky run.test-helper package (com.nowsprinting.test-helper) provides lightweight sampling helpers; reach for MathNet.Numerics only when you need rigorous statistics.Verify from the user's perspective — assert on-screen display and UI interactions as much as possible. Avoid relying on internal state or property checks when user-visible behavior can be asserted instead.
When the test target is a prefab, scene, or a GameObject composed of multiple components, consider the following test perspectives:
When the task type is bug-fix, additionally apply the following during technique selection:
For refactoring work, apply cover and modify: design regression coverage before changing the implementation. Treat every bug as an opportunity to grow the regression suite.
For each technique, derive coverage-aware test cases:
MethodName_Condition_ExpectedResult — the test target is a method, so include the method name.Condition_ExpectedResult — the test target is NOT a single method (it is a multi-component interaction or an on-screen rendering), so do NOT include a method name.Expected segment of the test method name. Describe observable behavior only; do NOT include any of the following anywhere in the test case output — this prohibition applies to the Verification column, Test perspectives descriptions, class header descriptions (text after #### ClassName), and any other field:
[Test], [UnityTest], [LoadScene], [Category(...)], [TakeScreenshot], etc.)PointerEventData, how to instantiate fixtures)LayoutAssert, GameObjectFinder)TestCase, Values, etc.) — that's a test-writing decision.Add_TwoIntegers_ReturnsSum (a: 0, 1, -1. b: 0, 1, 1) | 加算結果が引数の和になる(uses spy: <TargetDependency>). Do NOT note stubs or fakes — those are arrange/action concerns. xUTP definitions for reference:
(reproduction test) to the Test Method column (after the method name), not the Verification column.(saves screenshot for image analysis: element positions within screen, no overlap between elements, correct visibility state, text/background contrast).
<Condition> segment of the test method name — e.g., At960x540_RendersVersionLabelAtBottomRight (visual verification tests use Condition_ExpectedResult, with no method name). This makes each resolution a distinct, independently runnable test case.(saves screenshot for image analysis: ...) list when applicable:
| Style | Test Method | Verification |
|---------------------|----------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| Bad (mechanism) | OnBeginDrag_WhenDragStarts_BlocksRaycastsIsDisabled | Call OnBeginDrag synchronously with [Test] and Assert that CanvasGroup.blocksRaycasts == false |
| Good | OnBeginDrag_WhenDragStarts_BlocksRaycastsIsDisabled | CanvasGroup.blocksRaycasts is disabled when drag starts |
| Bad (rationale) | StartRun_SameSeed_ProducesSameMap | 同一シードで 2 回ランを開始したときマップ構造が再現されること。RNG が holder に格納されない現状では失敗する(BUG 1 の再現テスト) |
| Good | StartRun_SameSeed_ProducesSameMap (reproduction test) | 同一シードで 2 回ランを開始したときマップ構造が一致する |
| Bad (parameterized) | Sync_GivenPhase_PanelVisible | Defeat フェーズのときのみパネルが表示される(複数の引数パターンを検証) |
| Good | Sync_GivenPhase_PanelVisible (phase: HeroTurn, Defeat) | Defeat フェーズのときのみパネルが表示される |
The Bad (mechanism) row leaks the test-writing mechanism (attribute choice, sync invocation, exact assertion form).
The Bad (rationale) row leaks why the test exists and what the current behavior is — none of that belongs in Verification; (reproduction test) goes in the Test Method column instead.
The Bad (parameterized) row hides the concrete argument values in a vague phrase in Verification; they belong in the Test Method column as named parameters (param: val1, val2).
The Good rows state the observable behavior only; all other concerns go in the Test Method column or the test-writing phase.
After completing Section 4, perform a traceability pass (acceptance tests coverage check) before writing the final output:
Output a coverage summary table only when gaps were found or a requirement was explicitly waived. Omit the table when all requirements are covered without exception.
| Requirement (from prompt) | Covering test(s) | Gap / Waiver reason |
|---------------------------|-------------------------------|----------------------------------------------------|
| XXX should do Y | MethodName_ConditionA_DoesY | — |
| ZZZ must not allow W | (none) | Waived: prevented at a lower layer, not this class |
Output must contain the following blocks in this order:
### Editor tests### Unit tests### Integration tests### Visual verification tests### Manual testsNote: All layers may contain
(none)when no test cases apply to that layer. Do NOT write "Edit Mode" or "Play Mode" in test case output — that is a test-writing concern, not a design concern.
Structure by layer:
#### <ClassName> → ##### <MethodName> → Test perspectives → table#### <ClassName> → Test perspectives → table### Editor tests
#### <ClassName>
##### <MethodName>
Test perspectives: <techniques selected from Section 3, e.g., equivalence partitioning, boundary value analysis>
| Test Method | Verification |
|--------------------------------------------------|--------------------------------------------|
| `Method_Condition_Expected` | What is verified by this test |
| `Method_Condition_Expected` (reproduction test) | What is verified by this reproduction test |
| `Method_Condition_Expected` (param: val1, val2) | What is verified across these param values |
### Unit tests
#### <ClassName>
##### <MethodName>
Test perspectives: <techniques selected from Section 3>
| Test Method | Verification |
|--------------------------------------------------|--------------------------------------------|
| `Method_Condition_Expected` | What is verified by this test |
| `Method_Condition_Expected` | What is verified (uses spy: IDependency) |
### Integration tests
#### <ClassName>
Test perspectives: <class-level testing angles, e.g., multi-frame interaction, scene transition>
| Test Method | Verification |
|--------------------------------------------------|--------------------------------------------|
| `Condition_Expected` | What is verified by this test |
### Visual verification tests
#### <ClassName>
Test perspectives: <class-level visual aspects to verify, e.g., layout, contrast>
| Test Method | Verification |
|----------------------|-----------------------------------------------------------------------------------------------------------------|
| `Condition_Expected` | What is verified (saves screenshot for image analysis: element positions, no overlap, text/background contrast) |
### Manual tests
| Test Case | Test perspectives / Verification method |
|-----------------------------|--------------------------------------------|
| Brief description of item | Testing angle and how to verify |
After designing all test cases, evaluate and output a Testability Assessment at the end of your response.
Use one of the following labels:
| Label | Meaning |
|---------------------|--------------------------------------------------------------------------------------------------------|
| TESTABILITY: PASS | All public methods are independently testable; test case count is realistic |
| TESTABILITY: WARN | Localized concerns (e.g., too many test doubles, large integration tests, high FSM state combinations) |
| TESTABILITY: FAIL | Fundamental testability issues that require design revision |
FAIL criteria — flag FAIL if any of the following apply:
new inside constructor, etc.)Output format for the assessment section:
### Testability Assessment
TESTABILITY: PASS
or, for WARN/FAIL, include Testability Issues with specific problem locations and proposed remedies:
### Testability Assessment
TESTABILITY: FAIL
#### Testability Issues
| Issue | Location | Proposed Remedy |
|--------------------------------------------------------|----------------------|----------------------------------------|
| Hidden state: `_score` modified by private method only | `GameManager._score` | Expose via read-only property or event |
| Static coupling: `Random.Range` called directly | `CardSelector.Pick` | Inject `IRandomSource` interface |
testing
Orchestrates the test-first implementation planning workflow for feature implementation and spec changes. Use this skill whenever plan mode is active and the task involves implementing or adding a new feature, or changing an existing specification. Even if the user only says "plan this" or "how should we implement this", load this skill to ensure the full test-first planning workflow is followed.
testing
Diagnoses and fixes bugs using a test-first workflow (reproduce, diagnose, fix). Use this skill whenever the user reports a bug, describes unexpected behavior, or asks to investigate or fix a defect. Even if the user says "something's broken", "this isn't working", "fix this bug", or "why does X happen", load this skill to guide the full reproduce → diagnose → fix cycle.
development
Creates and modifies Unity scene and prefab files. Use this skill whenever creating, editing, or modifying .unity scene files or .prefab prefab files, or writing editor scripts under Assets/Editor/ that generate or manipulate scenes, prefabs, or scene-bound assets. This includes adding GameObjects, building uGUI hierarchies, wiring up components, and any task that results in changes to .unity or .prefab files.
tools
Provides guidelines for directly editing Unity YAML-serialized asset files for Unity projects. Make sure to use this skill whenever creating, editing, or modifying simple YAML asset files (ScriptableObjects, Materials, etc.) via Edit/Write tools without going through the Unity Editor. This includes adjusting ScriptableObject field values, modifying material shader properties, or any task that results in direct changes to allowlisted Unity YAML asset files. Even for small edits or one-line value changes, load this skill to ensure Unity asset-YAML conventions are followed.