unity-testability

Advises on extracting logic from MonoBehaviour classes and planning EditMode and PlayMode tests.

Updated Jun 21, 2026
One-click install
npx skills add https://github.com/du-qwq/Shader-Writing-Architecture-and-Specifications --skill unity-testability-du-qwq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-testability
Source: https://github.com/du-qwq/Shader-Writing-Architecture-and-Specifications/tree/main/.agents/skills/unity-skills/skills/testability
Command: npx skills add https://github.com/du-qwq/Shader-Writing-Architecture-and-Specifications --skill unity-testability-du-qwq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Unity code tightly coupled to MonoBehaviour, GameObject, and scene state is hard to unit test. This Skill helps you decide which logic should move into pure C# classes and which should stay Unity-facing, so you can build a practical EditMode/PlayMode test strategy. ## Core Features & Use Cases - Testability Review Questions: Structured prompts to check whether logic can run without Transform, GameObject, or scene state, and whether config can be injected instead of read from static globals. - Refactoring Guidance: Identifies logic to extract into plain C# classes called from thin MonoBehaviour wrappers, plus suggested seams and interfaces. - Test Planning: Produces candidate EditMode tests and PlayMode tests so you know what coverage each layer needs. - Use Case: You have a 300-line MonoBehaviour mixing input handling, scoring rules, and UI updates. Use this Skill to separate the scoring rules into a pure C# class, define an interface seam for input, and plan EditMode tests for the rules with PlayMode tests only for scene integration. ## Quick Start Ask the AI to review your Unity script for testability and suggest which logic to extract into pure C# classes with a plan for EditMode and PlayMode tests.

Frequently Asked Questions about unity-testability

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make Unity MonoBehaviour code unit testable?

Move logic that does not depend on Transform, GameObject, or scene state into plain C# classes, then call those classes from a thin MonoBehaviour. This lets you cover the core rules with fast EditMode tests while keeping Unity-facing glue minimal.

What is the difference between EditMode and PlayMode tests in Unity?

EditMode tests run in the editor without entering play mode and suit pure C# logic. PlayMode tests run in a live scene context and are needed for behaviour that depends on GameObjects, physics, or scene lifecycle.

How do I remove static global dependencies in Unity code?

Inject configuration through constructors or method parameters instead of reading static globals. This creates explicit seams that let tests substitute controlled values, making the logic deterministic and easier to verify.

When should I not extract logic out of a MonoBehaviour?

Avoid forced extraction when the script is tiny and inherently scene-bound, such as a short animation trigger. Prefer a few meaningful seams over abstraction for its own sake, since excessive interfaces add maintenance cost without test value.

Does this approach require extra Unity packages or frameworks?

No external packages are required beyond Unity's built-in Test Framework for EditMode and PlayMode tests. The guidance focuses on code structure decisions like seams, interfaces, and dependency injection rather than tooling.