unity-testability

Advises Unity refactors to extract pure C# logic and plan Edit/PlayMode tests.

8|1|Updated Oct 7, 2025
One-click install
npx skills add https://github.com/Zzulin/unity-project01 --skill unity-testability-zzulin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-testability
Source: https://github.com/Zzulin/unity-project01/tree/main/URP1/Plugins/Unity-Skills-main/SkillsForUnity/unity-skills~/skills/testability
Command: npx skills add https://github.com/Zzulin/unity-project01 --skill unity-testability-zzulin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps developers decide which logic should be moved out of Unity-facing classes into pure C# so code can be reliably unit tested and decoupled from scene state.

Core Features & Use Cases

  • Targeted Review Questions: Focuses on whether code depends on Transform, GameObject, or global static state and whether configuration can be injected.
  • Refactor Recommendations: Identifies logic to extract to plain C#, logic that should remain Unity-facing, and suggests seams/interfaces for dependency injection and mocking.
  • Test Planning: Produces candidate EditMode and PlayMode test ideas and outlines which behaviors require scene-driven validation versus isolated unit tests.
  • Use Case: When converting a feature to be testable (for CI, faster iteration, or clearer responsibilities), use this Skill to plan seams and test coverage.

Quick Start

Analyze the MonoBehaviour file 'PlayerController.cs' and recommend which methods and dependencies to extract into pure C#, suggest seams/interfaces, and list candidate 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 unit test MonoBehaviour scripts in Unity?

To unit test MonoBehaviour scripts in Unity, separate Unity-facing code from pure C# logic. Identify dependencies on Transform, GameObject, and scene state, then extract pure logic into isolated classes to enable reliable unit tests.

What is the best way to separate pure C# logic from Unity-facing code for testing?

Separating pure C# logic from Unity-facing code requires identifying direct dependencies on Transform, GameObject, or global static state. Recommend seams and dependency-injection approaches to decouple configuration and enable mocking without scene state.

How do I plan EditMode and PlayMode tests for a Unity system?

Plan EditMode and PlayMode tests by outlining which behaviors require scene-driven validation versus isolated unit tests. Identify candidate EditMode tests for pure C# logic and PlayMode tests for scene state and GameObject interactions within your Unity system.

Can I use dependency injection to improve testability in Unity?

Yes, dependency injection improves testability in Unity by decoupling MonoBehaviour scripts from scene state. Suggest seams and interfaces for mocking dependencies like Transform and GameObject, allowing logic to be reliably unit tested in EditMode.

Why do my Unity unit tests fail when they depend on Transform and GameObject?

Unity unit tests fail when depending on Transform and GameObject because these rely on scene state. Move logic out of Unity-facing classes into pure C# and use dependency injection to mock these dependencies, ensuring isolated test execution.