원클릭으로
unity-tests-write
Use when writing Unity tests, including EditMode tests, PlayMode tests, performance testing, and code coverage
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when writing Unity tests, including EditMode tests, PlayMode tests, performance testing, and code coverage
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Drive a GitHub issue — bare or tracked on a Project board — from triage to a merge-ready PR through a gated pipeline (design hardening, tests green, code-review clean), scaling the machinery to the task's tier and asking at most one batched question. Auto-links the issue to close on merge, advances the board card, then merges and cleans up once you approve the PR in-session. Triggers: "take task N", "work on issue #N", "do the next task", "build/fix X" when no issue exists yet, and — for the merge gate later — "merge it", "approve the PR", "ship it", "lgtm merge".
Slim or restructure an oversized CLAUDE.md into path-scoped .claude/rules/ files, verifying nothing was lost. Use when it exceeds ~200 lines, when Claude ignores instructions in it, or when choosing between CLAUDE.md, rules, skills and @import.
Use when removing AI-generation patterns from text in English or Russian. Auto-detects language by Cyrillic ratio and applies the matching ruleset. Trigger phrases: "humanize this", "remove AI patterns", "make this sound human", "очеловечить текст", "убрать признаки нейросети", "сделай текст живым". Honors explicit overrides like "humanize as English" / "обработай как русский". For mixed-language text, asks which ruleset to apply.
Reads input artifact(s) — codebase, planning session, refactor plan, or generic doc — and writes a tour-spec.json describing sections, embedded sources, cross-refs, quizzes, and external link maps. Use when the user wants a fresh learning guide built from source material; auto-hands-off to learning-guide:render. Trigger phrases — "create a learning guide for X", "make an interactive tour", "generate onboarding doc", "build a learning module".
Use when the user asks to "create a learning guide", "make an interactive tour", "generate onboarding doc", "build a learning module", or any variant of turning an artifact (codebase, planning session, refactor plan, design doc) into an interactive HTML guide. Dispatches to learning-guide:analyze for new tours or learning-guide:render for re-renders after spec edits. Also use when the user is uncertain which step they need.
Renders an existing tour-spec.json to a self-contained interactive HTML guide via the bundled Node renderer. Use when the user has hand-edited a tour-spec.json, when learning-guide:analyze hands off after drafting, or when the user explicitly asks to "render the tour", "regenerate the HTML", or "update the embedded sources". Idempotent for generated artifacts; preserves user-edited README and tour-spec.json.
| name | unity-tests-write |
| description | Use when writing Unity tests, including EditMode tests, PlayMode tests, performance testing, and code coverage |
You are a Unity testing specialist using Unity Test Framework.
Packages/manifest.json, asmdef test assemblies, CI scripts, and Unity version constraints)com.unity.test-framework version before choosing async test style (IEnumerator baseline vs async Task in newer UTF versions)For tests inside a project:
Tests/
├── Editor/
│ ├── <Company>.<Package>.Editor.Tests.asmdef
│ └── FeatureTests.cs
└── Runtime/
├── <Company>.<Package>.Tests.asmdef
└── FeaturePlayModeTests.cs
For UPM packages where tests must NOT ship with the package, use a separate test package:
MyPackage/ (published SDK — no tests)
├── Runtime/
├── Editor/
└── package.json
MyPackage.Tests/ (never published — internal only)
├── package.json
└── Editor/
├── com.company.package.tests.editor.asmdef
└── FeatureTests.cs
For tests in UPM packages to appear in Test Runner:
UNITY_INCLUDE_TESTS define constraint:{
"name": "com.company.package.tests.editor",
"references": ["com.company.package"],
"includePlatforms": ["Editor"],
"overrideReferences": true,
"precompiledReferences": ["nunit.framework.dll"],
"autoReferenced": false,
"defineConstraints": ["UNITY_INCLUDE_TESTS"]
}
testables:{
"dependencies": {
"com.company.package.tests": "file:../path/to/Package.Tests"
},
"testables": ["com.company.package.tests"]
}
Without testables, Unity will not compile or show tests from packages.
Use InternalsVisibleTo + internal visibility instead of making methods public just for testing:
In the runtime assembly (AssemblyInfo.cs):
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("com.company.package.tests.editor")]
In the code under test:
internal static bool SomeLogic(string input) { ... }
This keeps the public API clean while allowing test access.
using NUnit.Framework;
[TestFixture]
public class FeatureEditorTests
{
[SetUp]
public void Setup()
{
// Arrange common test setup
}
[TearDown]
public void TearDown()
{
// Cleanup
}
[Test]
public void MethodName_Condition_ExpectedResult()
{
// Arrange
var sut = new SystemUnderTest();
// Act
var result = sut.DoSomething();
// Assert
Assert.AreEqual(42, result);
}
}
Use [TestCase] when multiple inputs test the same behavior. Prefer over duplicate test methods:
[TestCase(null)]
[TestCase("")]
public void Parse_InvalidInput_ReturnsDefault(string input)
{
var result = Parser.Parse(input);
Assert.AreEqual(default, result);
}
[TestCase(1, 2, 3)]
[TestCase(0, 0, 0)]
[TestCase(-1, 1, 0)]
public void Add_VariousInputs_ReturnsSum(int a, int b, int expected)
{
Assert.AreEqual(expected, Calculator.Add(a, b));
}
For complex test data, use [TestCaseSource]:
private static IEnumerable<TestCaseData> EdgeCases()
{
yield return new TestCaseData("v1.0", "v1.0").Returns(true).SetName("Same version");
yield return new TestCaseData("v1.0", "v2.0").Returns(false).SetName("Different version");
}
[TestCaseSource(nameof(EdgeCases))]
public bool VersionCheck_EdgeCases(string saved, string current)
{
return VersionChecker.IsLoaded(saved, current);
}
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
public class FeaturePlayModeTests
{
private GameObject _testObject;
[SetUp]
public void Setup()
{
_testObject = new GameObject("TestObject");
}
[TearDown]
public void TearDown()
{
Object.Destroy(_testObject);
}
[UnityTest]
public IEnumerator ComponentBehavior_AfterOneFrame_ShouldUpdate()
{
var component = _testObject.AddComponent<TestComponent>();
yield return null;
Assert.IsTrue(component.HasUpdated);
}
}
[UnityTest] methods returning IEnumerator1.3+, UnityTest supports async Task; use this for modern async flows where it improves readability2023.1+ and Unity 6+, you can await UnityEngine.Awaitable inside async testsAwaitable as the test method return type; use Task or IEnumerator for test entry pointsAwaitable instance once onlyusing System.Threading.Tasks;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
public class FeatureAsyncPlayModeTests
{
[UnityTest]
public async Task ComponentBehavior_AfterOneFrame_ShouldUpdate()
{
var go = new GameObject("TestObject");
var component = go.AddComponent<TestComponent>();
#if UNITY_6000_0_OR_NEWER
await Awaitable.NextFrameAsync();
#else
await Task.Yield();
#endif
Assert.IsTrue(component.HasUpdated);
Object.Destroy(go);
}
}
Use Unity Performance Testing package for critical paths:
using NUnit.Framework;
using Unity.PerformanceTesting;
using UnityEngine;
public class PerformanceTests
{
[Test, Performance]
public void MyMethod_Performance()
{
Measure.Method(() =>
{
MyExpensiveMethod();
})
.WarmupCount(10)
.MeasurementCount(100)
.Run();
}
}
Use Unity Code Coverage package (com.unity.testtools.codecoverage):
Coverage Targets:
Running with coverage:
Unity -batchmode -projectPath "$(pwd)" -runTests -testPlatform EditMode -enableCodeCoverage -coverageResultsPath ./CodeCoverage -testResults ./TestResults/editmode.xml -quit
[SetUp] and [TearDown] for consistent test isolationMethodName_Condition_ExpectedResult[TestCase] for same-behavior-different-inputs instead of duplicate methodsinternal + InternalsVisibleTo instead of making methods public for testingUnityEngine.TestTools.LogAssert to verify expected log messages[TestCase]public solely for test access — use InternalsVisibleToAlways structure tests as:
[Test]
public void MethodName_Condition_ExpectedResult()
{
// Arrange
var input = CreateTestInput();
// Act
var result = systemUnderTest.Process(input);
// Assert
Assert.AreEqual(expected, result);
}