From unity-coding-skills
Provides Unity test conventions: GameObjectFinder over Find, Operators over direct events, internal/Integration/Acceptance categories, and UNITY_INCLUDE_TESTS guards.
How this skill is triggered — by the user, by Claude, or both
Slash command
/unity-coding-skills:test-writing-guideThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guide for writing test code for Unity projects.
Guide for writing test code for Unity projects.
mcp__jetbrains__unity_play_control tool first..meta files. Unity editor creates them automatically.internal visibility method, add [Category("Internal")] to the test method.[Category("Integration")] to the test method.(acceptance test) in the test case design), add [Category("Acceptance")] to the test method.GameObject, add [CreateScene] to the test method (not required if [LoadScene] is already present).internal accessor or a virtual override point to support injection), always wrap it with #if UNITY_INCLUDE_TESTS … #endif so it is excluded from non-test builds:
#if UNITY_INCLUDE_TESTS
internal void SetStateForTest(State state) => _state = state;
#endif
When finding a GameObject that the user interacts with, always use TestHelper.UI.GameObjectFinder instead of UnityEngine.GameObject.Find, Object.FindFirstObjectByType, Object.FindAnyObjectByType, and Object.FindObjectOfType.
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 in TestHelper.UI.Operators namespace) 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.GetComponent<Button>().onClick.Invoke();
inputField.GetComponent<InputField>().text = "12345";
scene.OnConfirmClicked();
// OK — goes through the proper UI event path
await new UguiClickOperator().OperateAsync(button);
await new UguiTextInputOperator().OperateAsync(inputField, "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("After running this test, verify the screenshots from the following perspectives: <verification aspects>")] to the test method. The verification aspects are taken directly from the Image analysis by saved screenshot column in the test case design.[Category("VisualVerification")] to the test method.Assert statements.Read the appropriate resource file based on the situation:
${CLAUDE_SKILL_DIR}/resources/unity-test-framework.md${CLAUDE_SKILL_DIR}/resources/test-helper.mdTestHelper.UI namespace API (e.g., GameObjectFinder, Monkey): Read ${CLAUDE_SKILL_DIR}/resources/test-helper-ui.mdnpx claudepluginhub nowsprinting/unity-coding-skills --plugin unity-coding-skillsGuides test case design for Unity projects: selects techniques, derives cases from requirements, and formats outputs. Activate when designing tests from specs.
Inspects, queries, and automates Unity UI (UI Toolkit / uGUI) via the `u` CLI. Dumps panel trees, clicks elements, reads text, runs monkey and visual regression tests.
Guides choosing between plain C#, edit mode, play mode, and smoke testing for Unity features. Useful when adding tests or fixing slow/brittle suites.