skills/test-writing-guide/SKILL.md
Provides guidelines for writing test code for Unity projects. Make sure to use this skill whenever writing, creating, editing, or modifying test code files (files under Tests/). This includes implementing new tests, fixing test failures, adding test cases, or any task that results in test code changes. Even for small edits or one-line fixes, load this skill to ensure test conventions are followed.
npx skillsauth add nowsprinting/claude-code-settings-for-unity test-writing-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 writing test code for Unity projects.
unity_play_control tool first..meta files. Unity editor creates them automatically.When implementing a test classified as an integration test, add [Category("Integration")] to the test method.
When finding a GameObject that the user interacts with, always use GameObjectFinder instead of UnityEngine.GameObject.Find or Object.FindFirstObjectByType.
Reasons:
reachable: true (default) naturally catches elements hidden behind a modal or overlay — which is often the bug being caughtTimeoutException with a clear message; GameObject.Find silently returns null and causes a confusing NullReferenceException laterWhen reproducing user actions, always use uGUI operators (e.g., UguiClickOperator, UguiTextInputOperator) instead of directly calling button events or setting field values.
Reasons:
EventSystem and input pipeline, exercising the same code path as a real user interaction// NG — bypasses Unity's event pipeline
button.onClick.Invoke();
inputField.text = "12345";
scene.OnConfirmClicked();
// OK — goes through the proper UI event path
await new UguiClickOperator().OperateAsync(buttonGo);
await new UguiTextInputOperator().OperateAsync(inputFieldGo, "12345");
When implementing a visual verification test (a test designed to verify on-screen rendering via screenshot and image analysis):
[TakeScreenshot] or ScreenshotHelper.TakeScreenshotAsync() (see test-helper.md).[Description("Verify the screenshots from the following perspectives: <verification aspects>")] to the test method. The verification aspects are taken directly from the (saves screenshot for image analysis: ...) note in the test case design.[Category("VisualVerification")] to the test method.Assert statements.Read the appropriate resource file based on the situation:
.claude/skills/test-writing-guide/resources/unity-test-framework.md.claude/skills/test-writing-guide/resources/test-helper.mdGameObjectFinder, Monkey, or uGUI operators): Read .claude/skills/test-writing-guide/resources/test-helper-ui.mdtesting
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.