unity-testing
БесплатноБез исполняемых скриптовНе проверенUnity Test Framework — EditMode + PlayMode tests, [UnityTest] coroutines, Test Runner, mocking patterns, Unity.PerformanceTesting package. USE WHEN…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Unity Test Framework
Test types
| Mode | What | Speed |
|---|---|---|
| EditMode | Pure C# logic, no scene | Fast (~ms) |
| PlayMode | Runs in play mode, can Instantiate, FixedUpdate ticks | Slow (seconds) |
Default to EditMode; reserve PlayMode for things that genuinely need the engine loop.
Asmdef setup
Assets/Tests/EditMode.asmdef (Test Assemblies + Editor-only references)
Assets/Tests/PlayMode.asmdef (Test Assemblies + runtime + editor)
Add Test Assemblies flag in asmdef Inspector.
EditMode test
using NUnit.Framework;
public class HealthTests {
[Test] public void TakeDamage_ReducesHealth() {
var h = new Health(100);
h.TakeDamage(30);
Assert.AreEqual(70, h.Current);
}
[TestCase(100, 200, 0)]
[TestCase(100, 50, 50)]
public void Damage_ClampsAtZero(int max, int dmg, int expected) {
var h = new Health(max);
h.TakeDamage(dmg);
Assert.AreEqual(expected, h.Current);
}
}
PlayMode test ([UnityTest])
using UnityEngine.TestTools;
using System.Collections;
using UnityEngine;
public class JumpTests {
[UnityTest] public IEnumerator Jump_LeavesGroundForOneSecond() {
var go = new GameObject("Player", typeof(Rigidbody), typeof(PlayerJump));
go.transform.position = Vector3.up;
var jump = go.GetComponent<PlayerJump>();
jump.DoJump();
yield return new WaitForSeconds(1f);
Assert.IsTrue(go.transform.position.y > 1f);
Object.Destroy(go);
}
}
yield return null → next frame; WaitForSeconds, WaitForFixedUpdate, WaitUntil(() => …).
Mocking time / input
- Time: inject an
ITimeabstraction that wrapsTime.deltaTime; in tests pass a fake. - Input: don't read
_action.ReadValuedirectly in test target — pass values via method, or useInputTestFixturefor low-level input simulation.
Performance tests (Unity.PerformanceTesting package)
[Test, Performance]
public void Pathfinder_PerfBaseline() {
Measure.Method(() => Pathfinder.FindPath(start, end, grid))
.WarmupCount(10)
.MeasurementCount(50)
.Run();
}
Reports captured to PerformanceTests folder; CI baselines via Performance Test Reporter.
CI integration
Unity -batchmode -projectPath . \
-runTests -testPlatform EditMode \
-testResults Tests/edit-results.xml \
-logFile - || exit 1
Unity -batchmode -projectPath . \
-runTests -testPlatform PlayMode \
-testResults Tests/play-results.xml \
-logFile - || exit 1
Convert *.xml (NUnit format) to JUnit for GitHub/GitLab reports.
Anti-patterns
| Anti-pattern | Fix |
|---|---|
| Tests sharing state via static fields | [SetUp] resets, or [TearDown] cleans |
Real time-based assertions (Thread.Sleep) |
Use yield return new WaitForSeconds in PlayMode |
| Loading actual scenes in EditMode | Refactor logic out of MonoBehaviour into POCOs you can unit test |
| One mega test method | Split into focused [Test] methods + [TestCase] data |
Production checklist
- Test asmdefs flagged Test Assemblies
- EditMode covers all POCO logic
- PlayMode reserved for engine-dependent behaviour
- Performance baselines tracked in CI
- Tests run in CI on every PR
- Random seeds reproducible (fix
Random.InitState(seed)in[SetUp])
Установить unity-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл unity-testing?
Unity Test Framework — EditMode + PlayMode tests, [UnityTest] coroutines, Test Runner, mocking patterns, Unity.PerformanceTesting package. USE WHEN: writing/debugging tests, setting up CI test runs, performance regression tests, asserting scene state, mocking time/input. DO NOT USE FOR: runtime in-game telemetry (use `unity-performance` for profiling); end-to-end automation (use editor tooling + custom harness).
Как установить скилл unity-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл unity-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic