unity-test
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBefore 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) first. If you already have the parameter definitions from recommend/schema, you may proceed straight to dryRun.GET /skills/recommend?includeSchema=true
调用本模块中的任何skill之前: 如果您打算根据名称或描述猜测参数来调用skill,请停止操作——先阅读本文档(或通过获取其schema)。如果您已经从推荐/schema中获得了参数定义,则可以直接进行dryRun。GET /skills/recommend?includeSchema=true
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)直接执行;执行/发现/创建型 skill(SkillMode.SemiAuto/test_run/test_run_by_name/test_discover_start/test_cancel/test_create_editmode,默认test_create_playmode)需用户 grant,grant 后服务端一步执行返结果(job 立即排进队列)。SkillMode.FullAuto -
Auto / Bypass: 直接执行。
-
本模块有 4 个 NeverInSemi skill(按自动判定):
IsForbiddenInSemi- :
MayEnterPlayMode = true、test_runtest_run_by_name - :
MayTriggerReload = true、test_create_editmode(同时标test_create_playmode)MutatesAssets = true
Approval 模式下这 4 个返,仅 Bypass 或 Allowlist 命中可绕过。注意:MODE_FORBIDDEN/test_run(testMode="PlayMode")会让 Unity TestRunner 切入 PlayMode;test_run_by_name/test_create_editmode落盘新的 .cs 文件后会触发 Domain Reload。test_create_playmode -
异步约定:/
test_run/test_run_by_name/test_discover_start立即返回test_create_*;用jobId/test_get_result(jobId)轮询;Unity TestRunner 串行化,正在跑测试时不要再起第二个test_discover_get_result(jobId)。test_run
DO NOT (common hallucinations):
- does not exist → use
test_run_allortest_runtest_run_by_name - does not exist → use
test_create_templateortest_create_editmodetest_create_playmode - does not exist → use
test_get_statuswithtest_get_resultfrom test runjobId - Test skills are async — they return a , poll with
jobIdtest_get_result(jobId) - Unity Test Runner is serialized here: do not start a second while another test job is still active
test_run - Prefer or
unity_skills.get_skills(category="Test")for exact signatures instead of guessing from memoryGET /skills/schema
Routing:
- For compile error checking → use module's
debugdebug_check_compilation - For test script creation → /
test_create_editmode, then modify viatest_create_playmodemodulescript - For broad regression probes across many skills → , which uses transient probes to avoid polluting workflow/batch persistence
test_smoke_skills
-
审批模式:只读skill(/
test_get_result/test_list/test_discover_get_result/test_get_last_result/test_list_categories/test_smoke_skills,标记为test_get_summary)可直接执行;执行/发现/创建类skill(SkillMode.SemiAuto/test_run/test_run_by_name/test_discover_start/test_cancel/test_create_editmode,默认test_create_playmode)需要用户授权(grant),授权后服务端一步执行并返回结果(任务立即排入队列)。SkillMode.FullAuto -
自动/绕过模式:直接执行。
-
本模块包含4个NeverInSemi skill(根据自动判定):
IsForbiddenInSemi- :
MayEnterPlayMode = true、test_runtest_run_by_name - :
MayTriggerReload = true、test_create_editmode(同时标记test_create_playmode)MutatesAssets = true
审批模式下这4个skill会返回,仅当命中绕过(Bypass)或白名单(Allowlist)时才能绕过限制。注意:MODE_FORBIDDEN/test_run(testMode="PlayMode")会让Unity TestRunner进入PlayMode;test_run_by_name/test_create_editmode生成新的.cs文件后会触发Domain Reload(域重载)。test_create_playmode -
异步约定:/
test_run/test_run_by_name/test_discover_start会立即返回test_create_*;使用jobId/test_get_result(jobId)进行轮询;Unity TestRunner是串行执行的,正在运行测试时请勿启动第二个test_discover_get_result(jobId)。test_run
请勿执行以下操作(常见误区):
- 不存在→请使用
test_run_all或test_runtest_run_by_name - 不存在→请使用
test_create_template或test_create_editmodetest_create_playmode - 不存在→请使用
test_get_status并传入测试运行返回的test_get_resultjobId - 测试Skills是异步的——它们会返回一个,需通过
jobId轮询结果test_get_result(jobId) - 此处Unity Test Runner是串行执行的:当有测试任务仍在运行时,请勿启动第二个
test_run - 建议使用或
unity_skills.get_skills(category="Test")获取准确的签名,而非凭记忆猜测GET /skills/schema
路由指引:
- 如需检查编译错误→使用模块的
debugdebug_check_compilation - 如需创建测试脚本→使用/
test_create_editmode,然后通过test_create_playmode模块进行修改script - 如需对多个skill进行广泛的回归探测→使用,它使用临时探测来避免污染工作流/批处理持久化
test_smoke_skills
Skills
Skills
test_list
test_listtest_list
test_listList available tests via Unity Test Runner async discovery. Returns + on first call (cache miss) — poll then retry .
Parameters:
pendingDiscovery=truediscoveryJobIdtest_discover_get_result(jobId)test_list- (string, optional): EditMode or PlayMode. Default: EditMode.
testMode - (int, optional): Max tests to list. Default: 100.
limit
Returns: — here is how many came back and is how many were discovered, means raise . ( uses for the total instead — see the warning there.)
{ success, testMode, count, total, truncated, tests, pendingDiscovery, discoveryJobId, discoveryStatus }counttotaltruncated: truelimittest_discover_get_resultcount通过Unity Test Runner异步发现功能列出可用测试。首次调用(缓存未命中)时会返回 + ——轮询后重试。
参数:
pendingDiscovery=truediscoveryJobIdtest_discover_get_result(jobId)test_list- (字符串,可选):EditMode或PlayMode。默认值:EditMode。
testMode - (整数,可选):最多列出的测试数量。默认值:100。
limit
返回值: ——其中是返回的测试数量,是发现的总测试数,表示需要提高的值。(中表示总测试数——请查看该接口的警告说明。)
{ success, testMode, count, total, truncated, tests, pendingDiscovery, discoveryJobId, discoveryStatus }counttotaltruncated: truelimittest_discover_get_resultcounttest_run
test_runtest_run
test_runRun Unity tests asynchronously. Returns a immediately; poll with .
Parameters:
jobIdtest_get_result(jobId)- (string, optional): EditMode or PlayMode. Default: EditMode. Returns:
testMode{ success, status, jobId, kind, testMode, filter, message }
异步运行Unity测试。立即返回;通过轮询结果。
参数:
jobIdtest_get_result(jobId)- (字符串,可选):EditMode或PlayMode。默认值:EditMode。 返回值:
testMode{ success, status, jobId, kind, testMode, filter, message }
test_get_result
test_get_resulttest_get_result
test_get_resultGet the result of a test run.
Parameters:
- (string, required): Job ID from
jobId/test_run.test_run_by_name
Returns: — each failure detail includes , , , , , and .
{ success, jobId, status, totalTests, passedTests, failedTests, skippedTests, inconclusiveTests, otherTests, failedTestNames, failedTestDetails, elapsedSeconds, resultSummary, error }nameresultStatemessagestackTracedurationSecondsoutput获取测试运行的结果。
参数:
- (字符串,必填):来自
jobId/test_run的任务ID。test_run_by_name
返回值: ——每个失败详情包含、、、、和。
{ success, jobId, status, totalTests, passedTests, failedTests, skippedTests, inconclusiveTests, otherTests, failedTestNames, failedTestDetails, elapsedSeconds, resultSummary, error }nameresultStatemessagestackTracedurationSecondsoutputtest_cancel
test_canceltest_cancel
test_cancelCancel a running test job if supported (Unity TestRunner has no hard cancel — best-effort).
Parameters:
- (string, required): Job ID to cancel.
jobId
Returns:
{ success, jobId, status, cancelled, note, warnings }如果支持的话,取消正在运行的测试任务(Unity TestRunner不支持强制取消——仅作尽力尝试)。
参数:
- (字符串,必填):要取消的任务ID。
jobId
返回值:
{ success, jobId, status, cancelled, note, warnings }test_discover_start
test_discover_starttest_discover_start
test_discover_startStart asynchronous Unity Test Runner discovery and return a discovery . Use this directly when you want explicit control over discovery; otherwise / will trigger it on cache miss.
jobIdtest_listtest_list_categories| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testMode | string | No | EditMode | EditMode or PlayMode |
Returns:
{ success, status, jobId, kind, testMode, message }启动Unity Test Runner异步发现任务并返回发现任务的。当您需要对发现过程进行显式控制时,请直接使用该接口;否则 / 会在缓存未命中时自动触发发现任务。
jobIdtest_listtest_list_categories| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testMode | string | No | EditMode | EditMode or PlayMode |
返回值:
{ success, status, jobId, kind, testMode, message }test_discover_get_result
test_discover_get_resulttest_discover_get_result
test_discover_get_resultGet 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 }Hereis the total andcountis what you got.returnedis how many tests the discovery found,countis how many are inreturnedaftertestswas applied,limitsays the two differ — raisetruncated: trueto see the rest. A project with 300 tests answerslimitunder the default. Never derive the suite size fromcount: 300, returned: 100, truncated: true.len(tests)⚠️means the opposite thing incount. Theretest_listis the returned length andcountis the discovered size; heretotalis the discovered size andcountis the returned length. The two skills were shipped that way and each one'sreturnedis frozen for wire compatibility, so do not assume symmetry — readcount(present on both) to know whether you are looking at a partial list, and take the total fromtruncatedintotalbut fromtest_listhere.count
获取Unity Test Runner异步发现任务的结果。
| 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 |
返回值:
{ success, jobId, status, testMode, discoveryMode, count, returned, truncated, tests, error }此处表示总测试数,count表示实际返回的数量。returned是发现任务找到的总测试数,count是应用returned限制后limit中的数量,tests表示两者不同——需要提高truncated: true值才能查看剩余测试。一个包含300个测试的项目在默认设置下会返回limit。切勿通过count: 300, returned: 100, truncated: true推导测试套件的总规模。len(tests)⚠️在count中的含义相反。 在test_list中,test_list是返回的测试数量,count是发现的总测试数;而在此处,total是发现的总测试数,count是返回的数量。这两个skill的returned定义因兼容性要求已固定,因此请勿假设两者对称——通过count(两个接口都有该字段)判断是否查看的是部分列表,从truncated的test_list获取总数量,从本接口的total获取总数量。count
test_run_by_name
test_run_by_nametest_run_by_name
test_run_by_nameRun 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 }按类名或方法名运行特定测试。
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testName | string | Yes | - | Test class or method name to run |
| testMode | string | No | EditMode | EditMode or PlayMode |
返回值:
{ success, jobId, testName, testMode }test_get_last_result
test_get_last_resulttest_get_last_result
test_get_last_resultGet 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_categoriestest_list_categories
test_list_categoriesList 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 }通过Unity Test Runner异步发现功能列出测试分类。与遵循相同的缓存未命中/轮询模式。
test_list| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| testMode | string | No | EditMode | EditMode or PlayMode |
返回值:
{ success, count, categories, pendingDiscovery, discoveryJobId, discoveryStatus }test_smoke_skills
test_smoke_skillstest_smoke_skills
test_smoke_skillsRun 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 }对已注册的skill运行可复用的冒烟测试。
| 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 |
返回值:
{ success, totalSkills, executedCount, dryRunCount, failureCount, results }test_create_editmode
test_create_editmodetest_create_editmode
test_create_editmodeCreate an EditMode test script template. Writes the .cs file synchronously and returns a compile-monitor ; the script create will trigger a Domain Reload, so the server may be temporarily unavailable — carries the transient-unavailable hint.
jobIdserverAvailability| 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 }创建EditMode测试脚本模板。同步写入.cs文件并返回编译监控;脚本创建会触发Domain Reload,因此服务器可能暂时不可用——字段会携带临时不可用的提示信息。
jobIdserverAvailability| 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 |
返回值:
{ success, status, path, testName, jobId, serverAvailability }test_create_playmode
test_create_playmodetest_create_playmode
test_create_playmodeCreate a PlayMode test script template. Writes the .cs file synchronously and returns a compile-monitor ; same Domain Reload + transient-unavailable note as .
jobIdtest_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 }创建PlayMode测试脚本模板。同步写入.cs文件并返回编译监控;与有相同的Domain Reload + 临时不可用说明。
jobIdtest_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 |
返回值:
{ success, status, path, testName, jobId, serverAvailability }test_get_summary
test_get_summarytest_get_summary
test_get_summaryGet 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, timepython
import unity_skills, timeRun 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)
undefinedfor _ 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)
undefinedExact Signatures
准确签名
Exact names, parameters, defaults, and returns are defined by or , not by this file.
GET /skills/schemaunity_skills.get_skill_schema()准确的名称、参数、默认值和返回值由或定义,而非本文档。
GET /skills/schemaunity_skills.get_skill_schema()