plugins/unity-dev-toolkit/skills/unity-test-runner/SKILL.md
Execute and analyze Unity Test Framework tests from the command line. This skill automates test execution for Unity projects by detecting the Unity Editor, configuring test parameters (EditMode/PlayMode), running tests via CLI, parsing XML results, and generating detailed failure reports. Use this when running Unity tests, validating game logic, or debugging test failures.
npx skillsauth add dev-gom/claude-code-marketplace unity-test-runnerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill enables automated execution and analysis of Unity Test Framework tests directly from the command line. It handles the complete test workflow: detecting Unity Editor installations across platforms (Windows/macOS/Linux), configuring test parameters, executing tests in EditMode or PlayMode, parsing NUnit XML results, and generating detailed failure reports with actionable insights.
Use this skill when:
Example user requests:
Follow this workflow when the skill is invoked:
Use the find-unity-editor.js script to automatically locate the Unity Editor:
node scripts/find-unity-editor.js --json
Script behavior:
--version <version> flagOutput:
{
"found": true,
"editorPath": "C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.15f1\\Editor\\Unity.exe",
"version": "2021.3.15f1",
"platform": "win32",
"allVersions": ["2021.3.15f1", "2020.3.30f1"]
}
If multiple versions are found:
If no Unity Editor is found:
Confirm the current directory contains a valid Unity project using cross-platform checks:
// Use Read tool to check for Unity project indicators
Read({ file_path: "ProjectSettings/ProjectVersion.txt" })
// Use Glob to verify Assets directory exists
Glob({ pattern: "Assets/*", path: "." })
Validation steps:
Assets/ directory existsProjectSettings/ProjectVersion.txt existsProjectVersion.txt to get Unity versionExample ProjectVersion.txt:
m_EditorVersion: 2021.3.15f1
m_EditorVersionWithRevision: 2021.3.15f1 (e8e88743f9e5)
Determine test execution parameters. Use AskUserQuestion tool if parameters are not specified:
Required settings:
Optional settings:
TestResults.xml in project rootConfiguration example:
AskUserQuestion({
questions: [{
question: "Which test mode should be executed?",
header: "Test Mode",
multiSelect: false,
options: [
{ label: "EditMode Only", description: "Fast unit tests without Play Mode" },
{ label: "PlayMode Only", description: "Full Unity engine tests" },
{ label: "Both Modes", description: "Run all tests (slower)" }
]
}]
})
Build and execute the Unity command line test command:
Command structure:
<UnityEditorPath> -runTests -batchmode -projectPath <ProjectPath> \
-testPlatform <EditMode|PlayMode> \
-testResults <OutputPath> \
[-testCategory <Categories>] \
[-testFilter <Filter>] \
-logFile -
Example commands:
EditMode tests:
"C:\Program Files\Unity\Hub\Editor\2021.3.15f1\Editor\Unity.exe" \
-runTests -batchmode \
-projectPath "D:\Projects\MyGame" \
-testPlatform EditMode \
-testResults "TestResults-EditMode.xml" \
-logFile -
PlayMode tests with category filter:
"C:\Program Files\Unity\Hub\Editor\2021.3.15f1\Editor\Unity.exe" \
-runTests -batchmode \
-projectPath "D:\Projects\MyGame" \
-testPlatform PlayMode \
-testResults "TestResults-PlayMode.xml" \
-testCategory "Combat;AI" \
-logFile -
Execution notes:
Bash tool with run_in_background: true for long-running testsExample execution:
Bash({
command: `"${unityPath}" -runTests -batchmode -projectPath "${projectPath}" -testPlatform EditMode -testResults "TestResults.xml" -logFile -`,
description: "Execute Unity EditMode tests",
timeout: 300000, // 5 minutes
run_in_background: true
})
After tests complete, parse the NUnit XML results using parse-test-results.js:
node scripts/parse-test-results.js TestResults.xml --json
Script output:
{
"summary": {
"total": 10,
"passed": 7,
"failed": 2,
"skipped": 1,
"duration": 12.345
},
"failures": [
{
"name": "TestPlayerTakeDamage",
"fullName": "Tests.Combat.PlayerTests.TestPlayerTakeDamage",
"message": "Expected: 90\n But was: 100",
"stackTrace": "at Tests.Combat.PlayerTests.TestPlayerTakeDamage () [0x00001] in Assets/Tests/Combat/PlayerTests.cs:42",
"file": "Assets/Tests/Combat/PlayerTests.cs",
"line": 42
}
],
"allTests": [...]
}
Result analysis:
For each failed test, analyze the failure using references/test-patterns.json:
Analysis steps:
Read({ file_path: "references/test-patterns.json" })
Match failure message against patterns:
Expected: <X> But was: <Y>Expected: not null But was: <null>TimeoutException|Test exceeded time limitCan't be called from.*main threadhas been destroyed|MissingReferenceExceptionDetermine failure category:
Generate fix suggestions:
Example failure analysis:
**Test**: Tests.Combat.PlayerTests.TestPlayerTakeDamage
**Location**: Assets/Tests/Combat/PlayerTests.cs:42
**Result**: FAILED
**Failure Message**:
Expected: 90
But was: 100
**Analysis**:
- Category: ValueMismatch (Assertion Failure)
- Pattern: Expected/actual value mismatch
- Root Cause: Player health not decreasing after TakeDamage() call
**Possible Causes**:
1. TakeDamage() method not implemented correctly
2. Player health not initialized properly
3. Damage value passed incorrectly
**Suggested Solutions**:
1. Verify TakeDamage() implementation:
```csharp
public void TakeDamage(int damage) {
health -= damage; // Ensure this line exists
}
Check test setup:
[SetUp]
public void SetUp() {
player = new Player();
player.Health = 100; // Ensure proper initialization
}
Verify test assertion:
player.TakeDamage(10);
Assert.AreEqual(90, player.Health); // Expected: 90
### 7. Generate Test Report
Create a comprehensive test report for the user:
**Report structure:**
```markdown
# Unity Test Results
## Summary
- **Total Tests**: 10
- **✓ Passed**: 7 (70%)
- **✗ Failed**: 2 (20%)
- **⊘ Skipped**: 1 (10%)
- **Duration**: 12.35s
## Test Breakdown
- **EditMode Tests**: 5 passed, 1 failed
- **PlayMode Tests**: 2 passed, 1 failed
## Failed Tests
### 1. Tests.Combat.PlayerTests.TestPlayerTakeDamage
**Location**: Assets/Tests/Combat/PlayerTests.cs:42
**Failure**: Expected: 90, But was: 100
**Analysis**: Player health not decreasing after TakeDamage() call.
**Suggested Fix**: Verify TakeDamage() implementation decreases health correctly.
---
### 2. Tests.AI.EnemyTests.TestEnemyChasePlayer
**Location**: Assets/Tests/AI/EnemyTests.cs:67
**Failure**: TimeoutException - Test exceeded time limit (5s)
**Analysis**: Infinite loop or missing yield in coroutine test.
**Suggested Fix**: Add `[UnityTest]` attribute and use `yield return null` in test loop.
---
## Next Steps
1. Review failed test locations and fix implementation
2. Re-run tests after fixes by re-invoking the skill
3. Consider adding more assertions for edge cases
Report delivery:
When using this skill:
Run EditMode tests first - They're faster and catch basic logic errors
Use test categories - Filter tests for faster iteration
-testCategory "Combat" runs only Combat testsMonitor test duration - Set appropriate timeouts
Check Unity version compatibility - Ensure Editor matches project version
Parse results immediately - Don't wait for manual review
Analyze failure patterns - Look for common causes
Preserve test results - Keep XML files for debugging
Handle long-running tests - Use background execution
BashOutput toolCross-platform Unity Editor path detection script. Automatically scans default installation directories for Windows, macOS, and Linux, detects all installed Unity versions, and returns the latest version or a specific requested version.
Usage:
# Find latest Unity version
node scripts/find-unity-editor.js --json
# Find specific version
node scripts/find-unity-editor.js --version 2021.3.15f1 --json
Output: JSON with Unity Editor path, version, platform, and all available versions.
NUnit XML results parser for Unity Test Framework output. Extracts test statistics, failure details, stack traces, and file locations from XML results.
Usage:
# Parse test results with JSON output
node scripts/parse-test-results.js TestResults.xml --json
# Parse with formatted console output
node scripts/parse-test-results.js TestResults.xml
Output: JSON with test summary, failure details including file paths and line numbers, and full test list.
Comprehensive database of Unity testing patterns, NUnit assertions, common failure patterns, and best practices. Includes:
Usage: Load this file when analyzing test failures to match failure messages against patterns and generate fix suggestions.
tools
Unity Editor control and automation, WebSocket-based real-time communication. 유니티에디터제어및자동화, WebSocket기반실시간통신. Features/기능: GameObject control 게임오브젝트제어, Transform manipulation 트랜스폼조작, Component management 컴포넌트관리, Scene management 씬관리, SQLite database integration SQLite데이터베이스통합, GUID-based persistence GUID기반영구식별, Multi-scene synchronization 멀티씬동기화, Command Pattern with Undo/Redo 명령패턴실행취소재실행, Menu execution 메뉴실행, ScriptableObject management 스크립터블오브젝트관리, Array/List manipulation 배열리스트조작, All field types support 모든필드타입지원, Material/Rendering 머티리얼/렌더링, Prefab system 프리팹시스템, Asset Database 애셋데이터베이스, Animation 애니메이션, Physics 물리, Console logging 콘솔로깅, EditorPrefs management 에디터프리퍼런스관리, Editor automation 에디터자동화, Build pipeline 빌드파이프라인, Lighting 라이팅, Camera 카메라, Audio 오디오, Navigation 네비게이션, Particles 파티클, Timeline 타임라인, UI Toolkit, Profiler 프로파일러, Test Runner 테스트러너. Protocol 프로토콜: JSON-RPC 2.0 over WebSocket (port 9500-9600). 500+ commands 명령어, 25 categories 카테고리. Real-time bidirectional communication 실시간양방향통신. Security 보안: Defense-in-depth 심층방어 (path traversal protection 경로순회방지, command injection defense 명령어인젝션방어, JSON injection prevention JSON인젝션방지, SQL injection prevention SQL인젝션방지, transaction safety 트랜잭션안전성). Localhost-only connections 로컬호스트전용. Cross-platform 크로스플랫폼 (Windows, macOS, Linux).
tools
Assists with Unity UI Toolkit development - UXML structure, USS styling, C# VisualElement manipulation, data binding, and custom controls. Use when implementing UI Toolkit interfaces.
tools
Guides selection between UGUI and UI Toolkit for projects. Use when choosing UI framework or migrating UI systems.
testing
Generates production-ready C# script templates (MonoBehaviour, ScriptableObject, Editor, tests). Use when creating new scripts or setting up project structure.