unity-test

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
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.
调用本模块中的任何skill之前: 如果您打算根据名称或描述猜测参数来调用skill,请停止操作——先阅读本文档(或通过
GET /skills/recommend?includeSchema=true
获取其schema)。如果您已经从推荐/schema中获得了参数定义,则可以直接进行dryRun。

Triggers

触发场景

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

Test Skills

测试Skills

Run and manage Unity tests.
运行并管理Unity测试。

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_name
    • MayTriggerReload = 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_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
  • 审批模式:只读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),授权后服务端一步执行并返回结果(任务立即排入队列)。
  • 自动/绕过模式:直接执行。
  • 本模块包含4个NeverInSemi skill(根据
    IsForbiddenInSemi
    自动判定):
    • MayEnterPlayMode = true
      :
      test_run
      、
      test_run_by_name
    • MayTriggerReload = true
      :
      test_create_editmode
      、
      test_create_playmode
      (同时标记
      MutatesAssets = true
      )
    审批模式下这4个skill会返回
    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
    。
请勿执行以下操作(常见误区):
  • test_run_all
    不存在→请使用
    test_run
    或
    test_run_by_name
  • test_create_template
    不存在→请使用
    test_create_editmode
    或
    test_create_playmode
  • test_get_status
    不存在→请使用
    test_get_result
    并传入测试运行返回的
    jobId
  • 测试Skills是异步的——它们会返回一个
    jobId
    ,需通过
    test_get_result(jobId)
    轮询结果
  • 此处Unity Test Runner是串行执行的:当有测试任务仍在运行时,请勿启动第二个
    test_run
  • 建议使用
    unity_skills.get_skills(category="Test")
    或
    GET /skills/schema
    获取准确的签名,而非凭记忆猜测
路由指引:
  • 如需检查编译错误→使用
    debug
    模块的
    debug_check_compilation
  • 如需创建测试脚本→使用
    test_create_editmode
    /
    test_create_playmode
    ,然后通过
    script
    模块进行修改
  • 如需对多个skill进行广泛的回归探测→使用
    test_smoke_skills
    ,它使用临时探测来避免污染工作流/批处理持久化

Skills

Skills

test_list

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.)
通过Unity Test Runner异步发现功能列出可用测试。首次调用(缓存未命中)时会返回
pendingDiscovery=true
+
discoveryJobId
——轮询
test_discover_get_result(jobId)
后重试
test_list
。 参数:
  • testMode
    (字符串,可选):EditMode或PlayMode。默认值:EditMode。
  • limit
    (整数,可选):最多列出的测试数量。默认值:100。
返回值:
{ success, testMode, count, total, truncated, tests, pendingDiscovery, discoveryJobId, discoveryStatus }
——其中
count
是返回的测试数量,
total
是发现的总测试数,
truncated: true
表示需要提高
limit
的值。(
test_discover_get_result
中
count
表示总测试数——请查看该接口的警告说明。)

test_run

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 }
异步运行Unity测试。立即返回
jobId
;通过
test_get_result(jobId)
轮询结果。 参数:
  • testMode
    (字符串,可选):EditMode或PlayMode。默认值:EditMode。 返回值:
    { success, status, jobId, kind, testMode, filter, message }

test_get_result

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
.
获取测试运行的结果。 参数:
  • jobId
    (字符串,必填):来自
    test_run
    /
    test_run_by_name
    的任务ID。
返回值:
{ success, jobId, status, totalTests, passedTests, failedTests, skippedTests, inconclusiveTests, otherTests, failedTestNames, failedTestDetails, elapsedSeconds, resultSummary, error }
——每个失败详情包含
name
、
resultState
、
message
、
stackTrace
、
durationSeconds
和
output
。

test_cancel

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 }
如果支持的话,取消正在运行的测试任务(Unity TestRunner不支持强制取消——仅作尽力尝试)。 参数:
  • jobId
    (字符串,必填):要取消的任务ID。
返回值:
{ success, jobId, status, cancelled, note, warnings }

test_discover_start

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.
ParameterTypeRequiredDefaultDescription
testModestringNoEditModeEditMode or PlayMode
Returns:
{ success, status, jobId, kind, testMode, message }
启动Unity Test Runner异步发现任务并返回发现任务的
jobId
。当您需要对发现过程进行显式控制时,请直接使用该接口;否则
test_list
/
test_list_categories
会在缓存未命中时自动触发发现任务。
ParameterTypeRequiredDefaultDescription
testModestringNoEditModeEditMode or PlayMode
返回值:
{ success, status, jobId, kind, testMode, message }

test_discover_get_result

test_discover_get_result

Get the result of an asynchronous Unity Test Runner discovery job.
ParameterTypeRequiredDefaultDescription
jobIdstringYes-Discovery job ID
limitintNo100Max 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.
获取Unity Test Runner异步发现任务的结果。
ParameterTypeRequiredDefaultDescription
jobIdstringYes-Discovery job ID
limitintNo100Max tests in the response; the default silently caps a larger suite
返回值:
{ success, jobId, status, testMode, discoveryMode, count, returned, truncated, tests, error }
此处
count
表示总测试数,
returned
表示实际返回的数量。
count
是发现任务找到的总测试数,
returned
是应用
limit
限制后
tests
中的数量,
truncated: true
表示两者不同——需要提高
limit
值才能查看剩余测试。一个包含300个测试的项目在默认设置下会返回
count: 300, returned: 100, truncated: true
。切勿通过
len(tests)
推导测试套件的总规模。
⚠️
count
在
test_list
中的含义相反。
在
test_list
中,
count
是返回的测试数量,
total
是发现的总测试数;而在此处,
count
是发现的总测试数,
returned
是返回的数量。这两个skill的
count
定义因兼容性要求已固定,因此请勿假设两者对称——通过
truncated
(两个接口都有该字段)判断是否查看的是部分列表,从
test_list
的
total
获取总数量,从本接口的
count
获取总数量。

test_run_by_name

test_run_by_name

Run specific tests by class or method name.
ParameterTypeRequiredDefaultDescription
testNamestringYes-Test class or method name to run
testModestringNoEditModeEditMode or PlayMode
Returns:
{ success, jobId, testName, testMode }
按类名或方法名运行特定测试。
ParameterTypeRequiredDefaultDescription
testNamestringYes-Test class or method name to run
testModestringNoEditModeEditMode or PlayMode
返回值:
{ success, jobId, testName, testMode }

test_get_last_result

test_get_last_result

Get the most recent test run result.
No parameters.
Returns:
{ jobId, status, total, passed, failed, skipped, inconclusive, other, failedNames }
获取最近一次测试运行的结果。
无参数。
返回值:
{ jobId, status, total, passed, failed, skipped, inconclusive, other, failedNames }

test_list_categories

test_list_categories

List test categories via Unity Test Runner async discovery. Same cache-miss / poll pattern as
test_list
.
ParameterTypeRequiredDefaultDescription
testModestringNoEditModeEditMode or PlayMode
Returns:
{ success, count, categories, pendingDiscovery, discoveryJobId, discoveryStatus }
通过Unity Test Runner异步发现功能列出测试分类。与
test_list
遵循相同的缓存未命中/轮询模式。
ParameterTypeRequiredDefaultDescription
testModestringNoEditModeEditMode or PlayMode
返回值:
{ success, count, categories, pendingDiscovery, discoveryJobId, discoveryStatus }

test_smoke_skills

test_smoke_skills

Run a reusable smoke test across registered skills.
ParameterTypeRequiredDefaultDescription
categorystringNo-Only test one skill category
nameContainsstringNo-Filter skills by partial name
excludeNamesCsvstringNo-Comma-separated skill names to exclude
executeReadOnlyboolNotrueExecute safe read-only skills directly
includeMutatingboolNotrueInclude mutating skills via dryRun smoke testing
limitintNo0Max skills to inspect; 0 means all
Returns:
{ success, totalSkills, executedCount, dryRunCount, failureCount, results }
对已注册的skill运行可复用的冒烟测试。
ParameterTypeRequiredDefaultDescription
categorystringNo-Only test one skill category
nameContainsstringNo-Filter skills by partial name
excludeNamesCsvstringNo-Comma-separated skill names to exclude
executeReadOnlyboolNotrueExecute safe read-only skills directly
includeMutatingboolNotrueInclude mutating skills via dryRun smoke testing
limitintNo0Max skills to inspect; 0 means all
返回值:
{ success, totalSkills, executedCount, dryRunCount, failureCount, results }

test_create_editmode

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.
ParameterTypeRequiredDefaultDescription
testNamestringYes-Name of the test class to create
folderstringNoAssets/Tests/EditorFolder path for the test script
Returns:
{ success, status, path, testName, jobId, serverAvailability }
创建EditMode测试脚本模板。同步写入.cs文件并返回编译监控
jobId
;脚本创建会触发Domain Reload,因此服务器可能暂时不可用——
serverAvailability
字段会携带临时不可用的提示信息。
ParameterTypeRequiredDefaultDescription
testNamestringYes-Name of the test class to create
folderstringNoAssets/Tests/EditorFolder path for the test script
返回值:
{ success, status, path, testName, jobId, serverAvailability }

test_create_playmode

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
.
ParameterTypeRequiredDefaultDescription
testNamestringYes-Name of the test class to create
folderstringNoAssets/Tests/RuntimeFolder path for the test script
Returns:
{ success, status, path, testName, jobId, serverAvailability }
创建PlayMode测试脚本模板。同步写入.cs文件并返回编译监控
jobId
;与
test_create_editmode
有相同的Domain Reload + 临时不可用说明。
ParameterTypeRequiredDefaultDescription
testNamestringYes-Name of the test class to create
folderstringNoAssets/Tests/RuntimeFolder path for the test script
返回值:
{ success, status, path, testName, jobId, serverAvailability }

test_get_summary

test_get_summary

Get aggregated test summary across all runs.
No parameters.
Returns:
{ success, totalRuns, completedRuns, totalPassed, totalFailed, totalSkipped, totalInconclusive, totalOther, allFailedTests }

获取所有测试运行的汇总统计信息。
无参数。
返回值:
{ success, totalRuns, completedRuns, totalPassed, totalFailed, totalSkipped, totalInconclusive, totalOther, allFailedTests }

Minimal Example

最小示例

python
import unity_skills, time
python
import unity_skills, time

Run tests and poll for result (async pattern required)

Run tests and poll for result (async pattern required)

result = unity_skills.call_skill("test_run", testMode="EditMode") job_id = result["jobId"]
result = unity_skills.call_skill("test_run", testMode="EditMode") job_id = result["jobId"]

Poll until done (test_* skills are async)

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)
undefined
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)
undefined

Exact Signatures

准确签名

Exact names, parameters, defaults, and returns are defined by
GET /skills/schema
or
unity_skills.get_skill_schema()
, not by this file.
准确的名称、参数、默认值和返回值由
GET /skills/schema
或
unity_skills.get_skill_schema()
定义,而非本文档。