/gametest 命令
来源:Commands/gametest,英文修订 ID:3187556。
此命令仅适用于基岩版,所需权限等级为 1,需要启用作弊。
运行包含 GameTest 脚本文件的附加包中的单元测试(也称 GameTest)。
用法
附加包可通过 GameTest 框架注册与 .mcstructure 文件配套的单元测试,参见 GameTest 基岩版。
放置结构方块并在其中输入 <testClassName>:<testName> 格式的测试 ID,然后执行 gametest runthis;多个结构方块可用 gametest runthese。结构方块中的“结构名称”应为单元测试 ID,而非结构本身的 ID。
gametest run ... 可自动放置测试结构并运行测试函数;gametest runset ... 可同时运行指定类的全部单元测试。
gametest create ... 可放置保存模式结构方块、磨制安山岩平台、三格厚泥土底座,以及附有石按钮的命令方块,便于开发者创建测试结构。
语法
| 命令 | 功能 |
|---|---|
gametest runthis |
寻找半径 15 格内最近的结构方块,运行其中指定 ID 的测试 |
gametest run <testName: string> <stopOnFailure: Boolean> <repeatCount: int> [rotationSteps: int] |
运行指定测试 |
gametest run <testName: string> [rotationSteps: int] |
运行指定测试 |
gametest runthese |
寻找半径 200 格内全部结构方块,运行其中指定 ID 的测试 |
gametest runset [tag: string] [rotationSteps: int] |
创建并运行指定类的全部测试 |
gametest clearall |
清除全部测试 |
gametest create <testName: string> [width: int] [height: int] [depth: int] |
放置结构方块、命令方块、磨制安山岩平台与泥土底座 |
gametest pos |
寻找半径 200 格内最近的结构方块 |
gametest stopall |
手动停止全部正在运行的测试 |
gametest runsetuntilfail [tag: string] [rotationSteps: int] |
创建并运行类内全部测试,任一失败时自动停止 |
参数
testName: string:作为 GameTest ID 的字符串。repeatCount: int:重复次数,必须为大于0的 32 位整数。stopOnFailure: Boolean:布尔值,指定当前测试失败后是否继续下一次重复(按原文参数说明保留)。rotationSteps: int:旋转步数,1为顺时针 90°,2为 180°,3为顺时针 270°,其他值不旋转。必须为 32 位整数。tag: string:要运行的已有 GameTest 类 ID。width: int:平台和结构在 X 轴的宽度,默认5,应不大于48。height: int:平台和结构在 Y 轴的高度,默认5,应不大于48。depth: int:平台和结构在 Z 轴的宽度,默认5,应不大于48。
各整数参数的基本类型范围均为 -2147483648 至 2147483647,并须满足上述额外限制。
外部链接
- Microsoft Learn:
/gametest命令,2023-10-11。
本文为 Minecraft Wiki 对应英文条目的中文翻译与改编,已按要求省略变更历史。原作者与贡献者见来源页及其历史;除另有说明外,按 CC BY-NC-SA 3.0 非商业、署名、相同方式共享。