unity-test

GitHub

用于在Unity引擎中异步执行、管理和轮询测试任务。支持EditMode和PlayMode测试的启动、发现、结果查询及测试文件生成,处理异步Job状态与模式限制。

SkillsForUnity/unity-skills~/skills/test/SKILL.md Besty0728/Unity-Skills

触发场景

运行Edit或Play模式测试 发现和列出可用测试用例 轮询异步测试结果 生成测试脚手架文件

安装

npx skills add Besty0728/Unity-Skills --skill unity-test -g -y
更多选项

非标准路径

npx skills add https://github.com/Besty0728/Unity-Skills/tree/main/SkillsForUnity/unity-skills~/skills/test -g -y

不安装直接使用

npx skills use Besty0728/Unity-Skills@unity-test

指定 Agent (Claude Code)

npx skills add Besty0728/Unity-Skills --skill unity-test -a claude-code -g -y

安装 repo 全部 skill

npx skills add Besty0728/Unity-Skills --all -g -y

预览 repo 内 skill

npx skills add Besty0728/Unity-Skills --list

SKILL.md

Frontmatter
{
    "name": "unity-test",
    "description": "Run Unity Test Runner operations asynchronously"
}

Before calling any skill in this module: if you are about to call a skill with parameters guessed from its name or description, STOP — read this file (or fetch its schema via GET /skills/recommend?includeSchema=true) first. If you already have the parameter definitions from recommend/schema, you may proceed straight to dryRun.

Triggers

  • Running EditMode/PlayMode tests
  • Discovering or listing tests
  • Polling async test results
  • Scaffolding test files
  • 运行 EditMode/PlayMode 测试、发现或列出测试、轮询异步测试结果、生成测试文件

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_runtest_run_by_name
    • MayTriggerReload = true: test_create_editmodetest_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_all does not exist → use test_run or test_run_by_name
  • test_create_template does not exist → use test_create_editmode or test_create_playmode
  • test_get_status does not exist → use test_get_result with jobId from test run
  • Test skills are async — they return a jobId, poll with test_get_result(jobId)
  • Unity Test Runner is serialized here: do not start a second test_run while another test job is still active
  • Prefer unity_skills.get_skills(category="Test") or GET /skills/schema for exact signatures instead of guessing from memory

Routing:

  • For compile error checking → use debug module's debug_check_compilation
  • For test script creation → test_create_editmode / test_create_playmode, then modify via script module
  • 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, total, truncated, tests, pendingDiscovery, discoveryJobId, discoveryStatus } — here count is how many came back and total is how many were discovered, truncated: true means raise limit. (test_discover_get_result uses count for the total instead — see the warning there.)

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 from test_run / test_run_by_name.

Returns: { success, jobId, status, totalTests, passedTests, failedTests, skippedTests, inconclusiveTests, otherTests, failedTestNames, failedTestDetails, elapsedSeconds, resultSummary, error } — each failure detail includes name, resultState, message, stackTrace, durationSeconds, and output.

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 in the response; the default silently caps a larger suite

Returns: { success, jobId, status, testMode, discoveryMode, count, returned, truncated, tests, error }

Here count is the total and returned is what you got. count is how many tests the discovery found, returned is how many are in tests after limit was applied, truncated: true says the two differ — raise limit to see the rest. A project with 300 tests answers count: 300, returned: 100, truncated: true under the default. Never derive the suite size from len(tests).

⚠️ count means the opposite thing in test_list. There count is the returned length and total is the discovered size; here count is the discovered size and returned is the returned length. The two skills were shipped that way and each one's count is frozen for wire compatibility, so do not assume symmetry — read truncated (present on both) to know whether you are looking at a partial list, and take the total from total in test_list but from count here.

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.

版本历史

  • 8c31c5a 当前 2026-08-27 12:45

    修复模块文档审计问题,更新地址资源文档与模板,修正幽灵场景引用、权限流程误导及模式标志等配置错误。

  • 5ee8388 2026-08-17 04:13

    根 SKILL.md 精简至 6.2KB,协议细节移至引用文件;新增 SKILL_GUIDE.md 指导模式文档;补充 manual-* 咨询模块及 Common Errors 章节;版本锚点更新至 2.6.0。

  • 25d511e 2026-08-13 09:16

    压缩SKILL.md描述至约5191字符,并将路由说明移至Triggers部分。

  • 2d2c709 2026-07-23 00:00

    版本更新至2.2.1,解决issue #49问题。

  • ec9f870 2026-07-05 14:41

同 Skill 集合

SkillsForUnity/unity-skills~/skills/addressables-design/SKILL.md
SkillsForUnity/unity-skills~/skills/addressables/SKILL.md
SkillsForUnity/unity-skills~/skills/adr/SKILL.md
SkillsForUnity/unity-skills~/skills/animator/SKILL.md
SkillsForUnity/unity-skills~/skills/behavior/SKILL.md
SkillsForUnity/unity-skills~/skills/blueprints/SKILL.md
SkillsForUnity/unity-skills~/skills/event/SKILL.md
SkillsForUnity/unity-skills~/skills/graphics/SKILL.md
SkillsForUnity/unity-skills~/skills/history/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-component/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-gameobject/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-material/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-scene/SKILL.md
SkillsForUnity/unity-skills~/skills/material/SKILL.md
SkillsForUnity/unity-skills~/skills/netcode-design/SKILL.md
SkillsForUnity/unity-skills~/skills/netcode/SKILL.md
SkillsForUnity/unity-skills~/skills/perception/SKILL.md
SkillsForUnity/unity-skills~/skills/pico-design/SKILL.md
SkillsForUnity/unity-skills~/skills/primetween/SKILL.md
SkillsForUnity/unity-skills~/skills/probuilder/SKILL.md
SkillsForUnity/unity-skills~/skills/profiler/SKILL.md
SkillsForUnity/unity-skills~/skills/project-scout/SKILL.md
SkillsForUnity/unity-skills~/skills/qframework-design/SKILL.md
SkillsForUnity/unity-skills~/skills/sample/SKILL.md
SkillsForUnity/unity-skills~/skills/shadergraph-design/SKILL.md
SkillsForUnity/unity-skills~/skills/SKILL.md
SkillsForUnity/unity-skills~/skills/smart/SKILL.md
SkillsForUnity/unity-skills~/skills/unity-cli/SKILL.md
SkillsForUnity/unity-skills~/skills/yaml-editing/SKILL.md
SkillsForUnity/unity-skills~/SKILL.md
SkillsForUnity/unity-skills~/skills/architecture/SKILL.md
SkillsForUnity/unity-skills~/skills/asmdef/SKILL.md
SkillsForUnity/unity-skills~/skills/asset/SKILL.md
SkillsForUnity/unity-skills~/skills/async/SKILL.md
SkillsForUnity/unity-skills~/skills/batch/SKILL.md
SkillsForUnity/unity-skills~/skills/bookmark/SKILL.md
SkillsForUnity/unity-skills~/skills/camera/SKILL.md
SkillsForUnity/unity-skills~/skills/cinemachine/SKILL.md
SkillsForUnity/unity-skills~/skills/cleaner/SKILL.md
SkillsForUnity/unity-skills~/skills/component/SKILL.md
SkillsForUnity/unity-skills~/skills/console/SKILL.md
SkillsForUnity/unity-skills~/skills/debug/SKILL.md
SkillsForUnity/unity-skills~/skills/decal/SKILL.md
SkillsForUnity/unity-skills~/skills/dotween-design/SKILL.md
SkillsForUnity/unity-skills~/skills/dotween/SKILL.md
SkillsForUnity/unity-skills~/skills/editor/SKILL.md
SkillsForUnity/unity-skills~/skills/gameobject/SKILL.md
SkillsForUnity/unity-skills~/skills/hybridclr/SKILL.md
SkillsForUnity/unity-skills~/skills/importer/SKILL.md
SkillsForUnity/unity-skills~/skills/inspector/SKILL.md

元信息

文件数
0
版本
e53e50f
Hash
b33aa20d
收录时间
2026-07-05 14:41

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-17 15:20
浙ICP备14020137号-1