unity-test
Unity Test Runner async operations — run / discover / list / cancel tests, poll job results, create EditMode/PlayMode test templates, list categories, run skills smoke regression. All run/discover skills are job-based: they return jobId immediately and you poll with test_get_result / test_discover_get_result. Triggers: test, unit test, automated test, integration test, test runner, NUnit, EditMode, PlayMode, edit mode test, play mode test, run tests, run all tests, run by name, run by category, list tests, discover tests, test categories, test result, test status, async test, poll test result, jobId, job poll, async job, cancel test, abort test, create test template, EditMode template, PlayMode template, smoke test, regression test, skill smoke, test summary, last test result, test_run, test_run_by_name, test_get_result, test_get_last_result, test_list, test_list_categories, test_discover_start, test_discover_get_result, test_cancel, test_create_editmode, test_create_playmode, test_smoke_skills…
- License 许可
- MIT
- 最近更新
- 2026-07-25
- Stars
- ★ 8
- Forks
- 0
01 前言 Front Matter
- name
- unity-test
- metadata
- { "tier": 2, "source": "https://github.com/Besty0728/Unity-Skills", "version": "1.9.2" }
- use-when
- Load when the task requires: Unity Test Runner async operations — run / discover / list / cancel tests, poll job results, create EditMode/PlayMode test templates, list categories, run skills smoke regression. All run/discover skills are job-based: they return jobId immediately and you poll with test_get_result / test_discover_get_result. Unity Editor must be running with the unity-skills REST server reachable at http://localhost:8090.
- platforms
- [ "unity-editor", "claude-code" ]
- description
- Unity Test Runner async operations — run / discover / list / cancel tests, poll job results, create EditMode/PlayMode test templates, list categories, run skills smoke regression. All run/discover skills are job-based: they return jobId immediately and you poll with test_get_result / test_discover_get_result. Triggers: test, unit test, automated test, integration test, test runner, NUnit, EditMode, PlayMode, edit mode test, play mode test, run tests, run all tests, run by name, run by category, list tests, discover tests, test categories, test result, test status, async test, poll test result, jobId, job poll, async job, cancel test, abort test, create test template, EditMode template, PlayMode template, smoke test, regression test, skill smoke, test summary, last test result, test_run, test_run_by_name, test_get_result, test_get_last_result, test_list, test_list_categories, test_discover_start, test_discover_get_result, test_cancel, test_create_editmode, test_create_playmode, test_smoke_skills…
- do-not-use-when
- Do not load when Unity Editor is not running locally. Do not load when unity-skills REST server is unreachable at http://localhost:8090. For compile error checking → use `debug` module instead.
- task-categories
- [ "testing", "edit-mode-tests", "editor-automation" ]
03 SKILL.md 正文
Test Skills
Run and manage Unity tests.
Operating Mode
-
Approval(默认): 只读 skill(
test_get_result/test_list/test_discover_get_result/test_get_last_result/test_list_categories/test_smoke_skills/test_get_summary,标SkillMode.SemiAuto)直接执行;执行/发现/创建型 skill(test_run/test_run_by_name/test_discover_start/test_cancel/test_create_editmode/test_create_playmode,默认SkillMode.FullAuto)需用户 grant,grant 后服务端一步执行返结果(job 立即排进队列)。 -
Auto / Bypass: 直接执行。
-
本模块有 4 个 NeverInSemi skill(按
IsForbiddenInSemi自动判定):MayEnterPlayMode = true:test_run、test_run_by_nameMayTriggerReload = true:test_create_editmode、test_create_playmode(同时标MutatesAssets = true)
Approval 模式下这 4 个返
MODE_FORBIDDEN,仅 Bypass 或 Allowlist 命中可绕过。注意:test_run(testMode="PlayMode")/test_run_by_name会让 Unity TestRunner 切入 PlayMode;test_create_editmode/test_create_playmode落盘新的 .cs 文件后会触发 Domain Reload。 -
异步约定:
test_run/test_run_by_name/test_discover_start/test_create_*立即返回jobId;用test_get_result(jobId)/test_discover_get_result(jobId)轮询;Unity TestRunner 串行化,正在跑测试时不要再起第二个test_run。
DO NOT (common hallucinations):
test_run_alldoes not exist → usetest_runortest_run_by_nametest_create_templatedoes not exist → usetest_create_editmodeortest_create_playmodetest_get_statusdoes not exist → usetest_get_resultwithjobIdfrom test run- Test skills are async — they return a
jobId, poll withtest_get_result(jobId) - Unity Test Runner is serialized here: do not start a second
test_runwhile another test job is still active - Prefer
unity_skills.get_skills(category="Test")orGET /skills/schemafor exact signatures instead of guessing from memory
Routing:
- For compile error checking → use
debugmodule'sdebug_check_compilation - For test script creation →
test_create_editmode/test_create_playmode, then modify viascriptmodule - For broad regression probes across many skills →
test_smoke_skills, which uses transient probes to avoid polluting workflow/batch persistence
Skills
test_list
List available tests via Unity Test Runner async discovery. Returns pendingDiscovery=true + discoveryJobId on first call (cache miss) — poll test_discover_get_result(jobId) then retry test_list.
Parameters:
testMode(string, optional): EditMode or PlayMode. Default: EditMode.limit(int, optional): Max tests to list. Default: 100.
Returns: { success, testMode, count, tests, pendingDiscovery, discoveryJobId, discoveryStatus }
test_run
Run Unity tests asynchronously. Returns a jobId immediately; poll with test_get_result(jobId).
Parameters:
testMode(string, optional): EditMode or PlayMode. Default: EditMode. Returns:{ success, status, jobId, kind, testMode, filter, message }
test_get_result
Get the result of a test run. Parameters:
jobId(string, required): Job ID fromtest_run/test_run_by_name.
Returns: { success, jobId, status, totalTests, passedTests, failedTests, skippedTests, inconclusiveTests, otherTests, failedTestNames, elapsedSeconds, resultSummary, error }
test_cancel
Cancel a running test job if supported (Unity TestRunner has no hard cancel — best-effort). Parameters:
jobId(string, required): Job ID to cancel.
Returns: { success, jobId, status, cancelled, note, warnings }
test_discover_start
Start asynchronous Unity Test Runner discovery and return a discovery jobId. Use this directly when you want explicit control over discovery; otherwise test_list / test_list_categories will trigger it on cache miss.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testMode | string | No | EditMode | EditMode or PlayMode |
Returns: { success, status, jobId, kind, testMode, message }
test_discover_get_result
Get the result of an asynchronous Unity Test Runner discovery job.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| jobId | string | Yes | - | Discovery job ID |
| limit | int | No | 100 | Max tests to return |
Returns: { success, jobId, status, testMode, discoveryMode, count, tests, error }
test_run_by_name
Run specific tests by class or method name.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testName | string | Yes | - | Test class or method name to run |
| testMode | string | No | EditMode | EditMode or PlayMode |
Returns: { success, jobId, testName, testMode }
test_get_last_result
Get the most recent test run result.
No parameters.
Returns: { jobId, status, total, passed, failed, skipped, inconclusive, other, failedNames }
test_list_categories
List test categories via Unity Test Runner async discovery. Same cache-miss / poll pattern as test_list.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testMode | string | No | EditMode | EditMode or PlayMode |
Returns: { success, count, categories, pendingDiscovery, discoveryJobId, discoveryStatus }
test_smoke_skills
Run a reusable smoke test across registered skills.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| category | string | No | - | Only test one skill category |
| nameContains | string | No | - | Filter skills by partial name |
| excludeNamesCsv | string | No | - | Comma-separated skill names to exclude |
| executeReadOnly | bool | No | true | Execute safe read-only skills directly |
| includeMutating | bool | No | true | Include mutating skills via dryRun smoke testing |
| limit | int | No | 0 | Max skills to inspect; 0 means all |
Returns: { success, totalSkills, executedCount, dryRunCount, failureCount, results }
test_create_editmode
Create an EditMode test script template. Writes the .cs file synchronously and returns a compile-monitor jobId; the script create will trigger a Domain Reload, so the server may be temporarily unavailable — serverAvailability carries the transient-unavailable hint.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testName | string | Yes | - | Name of the test class to create |
| folder | string | No | Assets/Tests/Editor | Folder path for the test script |
Returns: { success, status, path, testName, jobId, serverAvailability }
test_create_playmode
Create a PlayMode test script template. Writes the .cs file synchronously and returns a compile-monitor jobId; same Domain Reload + transient-unavailable note as test_create_editmode.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testName | string | Yes | - | Name of the test class to create |
| folder | string | No | Assets/Tests/Runtime | Folder path for the test script |
Returns: { success, status, path, testName, jobId, serverAvailability }
test_get_summary
Get aggregated test summary across all runs.
No parameters.
Returns: { success, totalRuns, completedRuns, totalPassed, totalFailed, totalSkipped, totalInconclusive, totalOther, allFailedTests }
Minimal Example
import unity_skills, time
# Run tests and poll for result (async pattern required)
result = unity_skills.call_skill("test_run", testMode="EditMode")
job_id = result["jobId"]
# Poll until done (test_* skills are async)
for _ in range(30):
status = unity_skills.call_skill("test_get_result", jobId=job_id)
if status.get("status") == "Completed":
print(f"Passed: {status['totalPassed']}, Failed: {status['totalFailed']}")
break
time.sleep(2)
Exact Signatures
Exact names, parameters, defaults, and returns are defined by GET /skills/schema or unity_skills.get_skill_schema(), not by this file.
04 同仓库更多 Skills
dots-update-groups
How to choose the right ECS system group and ordering so per-frame and per-fixed-step work is deterministic and never races its own readers. Covers InitializationSystemGroup / SimulationSystemGroup / PresentationSystemGroup / FixedStepSimulationSystemGroup / VariableRateSimulationSystemGroup, UpdateBefore / UpdateAfter peer ordering, OrderFirst / OrderLast group-boundary placement, RateManager, and the cross-group ordering trap. Use when adding an ISystem, fixing "value visible one frame late" bugs, or coupling simulation to a fixed timestep.
dots-transform-patterns
The Entities 1.x transform model — LocalTransform (writable input) vs LocalToWorld (system-owned matrix), Parent/Child hierarchy, reparenting cost, uniform vs non-uniform scale (PostTransformMatrix), and when to opt out with custom transform systems. Use when designing parent/child hierarchies, runtime reparenting (mount/dismount/socket), or choosing transform components at the Baker boundary.
dots-singleton-patterns
Model cross-system shared configuration and game state as a single-entity component with a strict single-writer contract. Covers RequireForUpdate gating, SystemAPI.GetSingleton / GetSingletonRW / HasSingleton / TryGetSingleton, bake-time vs runtime-created vs ECB-system singletons, the "exactly one entity" runtime invariant, and the single-writer rule. Use when designing frame-stable global config, shared mutable state, or any component intended to exist on exactly one entity.
dots-hybrid-bridge
The one-way bridge between DOTS-owned runtime state and Unity-owned presentation. Covers UnityObjectRef for managed asset refs in components, the DOTS-writes / Unity-reads ownership rule, when to use managed IComponentData vs UnityObjectRef vs CompanionComponent, baker-bridge vs runtime-bridge, and SubScene boundary rules. Use when an entity must reference Unity assets (Mesh, Material, AudioClip, ScriptableObject), a MonoBehaviour view must read entity state, or input/UI must trigger ECS work.
dots-event-driven-ecs
Model one-frame events and external requests in ECS without dual ownership, polling, or persistent state leaks. Covers request-tag pattern with ECB, enableable command components (no structural change), event buffers (IBufferElementData), explicit consumer ownership, one-frame latency rules, and the banned C# event / UnityEvent / static bus anti-patterns. Use when input/UI/network must trigger ECS work, when a one-frame signal fans out to N consumers (damage, hit, collision), or when state changes must be processed exactly once.
valid_skill
A complete, well-formed test fixture skill for SkillHub validation testing. Covers basic task routing and code review for Unity projects.