Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

unity-test-framework

БесплатноБез исполняемых скриптовНе проверен

Use for any question or task about testing C# code in a Unity game-engine project, even a single PlayMode test for a MonoBehaviour: Unity Test Framework…

testlandот testland★ 18 звёзд на GitHub

Об этом скилле

unity-test-framework

Overview

Disambiguation up front. This skill covers the Unity game-engine Test Framework - the official Unity package com.unity.test-framework documented at docs.unity3d.com/Packages/com.unity.test-framework@latest. It is distinct from the ThrowTheSwitch Unity C testing library at throwtheswitch.org/unity (a single-C-file unit-test framework for bare-metal MCUs). The two tools share only a name; they have unrelated origins, APIs, and consumers. For the C unit-test library, see the sibling skill unity-test-framework-c in the qa-embedded plugin.

UTF is built on NUnit 3.5 and supports both Edit Mode and Play Mode across Standalone, Android, and iOS target platforms (per the package overview).

Versioning. UTF is currently v1.8; the stable doc links below pin to the v1.4 manual snapshot for durable URLs. Both describe the same package.

Composes with:

  • platform-cert-overview-reference for what category of test each Unity test belongs to (functional / performance / etc.), and for cert-gated requirements UTF tests should cover (XR-001 Title Stability, XR-074 Service Loss, XR-115 Controller add / remove).
  • multiplayer-state-machine-coverage and gameplay-recording-replay for state-machine and replay-driven test patterns inside UTF PlayMode tests.

When to use

  • Unit under test is C# Unity code that needs the Unity runtime (MonoBehaviour, GameObject, coroutines, scenes) or editor (AssetDatabase, EditorWindow) APIs available.
  • You want CI-runnable tests that integrate with Unity Cloud Build, GitHub Actions, or other CI via Unity's batch-mode CLI.
  • You need both isolated logic tests (EditMode) and integration tests that exercise scene lifecycle (PlayMode) in one harness.

For C unit tests on the firmware side of a hybrid game build, use unity-test-framework-c instead.

Authoring

Install via Package Manager

UTF "is shipped with the Unity Editor and should be automatically included in any project created with Unity 2019.2 or later" (per the package overview). For manual install, open Package Manager → + → "Add package by name…" → com.unity.test-framework.

The Test Runner window is at Window → General → Test Runner (may be Window → Test Runner depending on Editor version).

EditMode tests

Per the Edit Mode vs Play Mode tests page, Edit Mode tests "are only run in the Unity Editor and have access to the Editor code in addition to the game code".

Layout (two options):

  • Editor folder (legacy): place tests under any folder named Editor/. Unity auto-scopes them to the Editor platform.
  • Assembly definition (recommended): create an .asmdef with "includePlatforms": ["Editor"].

Minimal example:

using NUnit.Framework;
using UnityEngine;

namespace MyGame.Tests.EditMode
{
    public class HealthComponentTests
    {
        [Test]
        public void Damage_DeductsCorrectAmount()
        {
            var go = new GameObject();
            var health = go.AddComponent<HealthComponent>();
            health.Initialize(maxHealth: 100);

            health.ApplyDamage(35);

            Assert.AreEqual(65, health.Current);
        }

        [TearDown]
        public void Cleanup()
        {
            // EditMode tests must clean up created GameObjects;
            // they don't auto-tear-down between cases.
        }
    }
}

The docs recommend the NUnit Test attribute rather than UnityTest unless you need to yield special instructions in Edit Mode, or skip a frame / wait for an amount of time in Play Mode.

PlayMode tests

PlayMode tests "execute as coroutines within the game runtime and can run standalone in a Player or within the Editor". Assembly definition:

{
  "name": "MyGame.Tests.PlayMode",
  "references": ["MyGame.Runtime"],
  "optionalUnityReferences": ["TestAssemblies"],
  "includePlatforms": []
}

Per the edit-mode-vs-play-mode docs, the .asmdef must reference the code under test ("references": ["NewAssembly"]), optionally include "optionalUnityReferences": ["TestAssemblies"], and leave "includePlatforms": [] empty to allow multiple target platforms.

Minimal example:

using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace MyGame.Tests.PlayMode
{
    public class EnemyAITests
    {
        [UnityTest]
        public IEnumerator Enemy_PursuesPlayer_WithinRange()
        {
            var player = new GameObject("Player");
            var enemy  = Object.Instantiate(Resources.Load<GameObject>("Enemy"));
            enemy.transform.position = new Vector3(
Полный SKILL.md на GitHub

Установить unity-test-framework в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonreferences/attributes.mdreferences/cli.mdreferences/results-and-ci.md

FAQ

Что делает скилл unity-test-framework?

Use for any question or task about testing C# code in a Unity game-engine project, even a single PlayMode test for a MonoBehaviour: Unity Test Framework EditMode vs PlayMode tests, [Test] and [UnityTest], assembly definitions, the Test Runner window, batch-mode command-line runs and CI. Not the ThrowTheSwitch C library.

Как установить скилл unity-test-framework?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл unity-test-framework запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить unity-test-framework с