/gametest
/gametest| Permission level required |
1 |
|---|---|
| Restrictions |
Cheat only |
{
"title": "<code>/gametest</code>",
"rows": [
{
"field": "1",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "(link to Option article, displayed as Cheat) only<br>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Runs a unit test (also called a GameTest) from an add-on package containing GameTest script files.
Usage
A unit test (or GameTest) can be registered in an add-on using the GameTest framework, which is paired with a .mcstructure file. See GameTest § Bedrock Edition.
Place a structure block and type the ID (in the format of <testClassName>:<testName>) in it, then execute gametest runthis (or gametest runthese for multiple structure blocks) to run the unit test in the world. Note that the "structure name" in structure block should be the ID of the unit test instead of structure's ID.
gametest run .. can automatically place the test structure and run the test function from a unit test.
gametest runset ... can automatically run all unit tests in the specified class at the same time.
gametest create .. can place a save mode structure block, a platform made of polished andesite, there-block-thick dirt base, and a command block with a stone button attached on it. It is useful for developers to create a new structure for the unit test.
Syntax
gametest runthis- Finds the nearest structure block within 15 blocks radius, and then tries to run GameTest with the ID specified in the structure block.
gametest run <testName: string> <stopOnFailure: Boolean> <repeatCount: int> [rotationSteps: int]gametest run <testName: string> [rotationSteps: int]- Runs a specific GameTest.
gametest runthese- Finds all structure blocks within 200 blocks radius, and then tries to run GameTests with the IDs specified in the structure blocks.
gametest runset [tag: string] [rotationSteps: int]- Creates and runs all GameTests in this class (
tag: GameTestTag).
- Creates and runs all GameTests in this class (
gametest clearall- Clears all GameTests.
gametest create <testName: string> [width: int] [height: int] [depth: int]- Places structure block, command block, and polished andesite platform and dirt base.
gametest pos- Finds nearest structure block within 200 blocks radius.
gametest stopall- Manually stops all tests while they are running.
gametest runsetuntilfail [tag: string] [rotationSteps: int]- Creates and runs all GameTests in the class, but automatically stops if any of the tests fail.
Arguments
testName: string: string
- Specified a string as gametest ID.
- Must be a string. And it must be a single word that has no space or a double-quoted string (When quoted,
\can be used to escape characters).
repeatCount: int: int
- Specifies the times the gametest repeats.
- Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). And it must greater than 0.
stopOnFailure: Boolean: enum
- Specifies whether to continue with the next repetition when current test fails.
- Must be a [Boolean]Boolean (either
trueorfalse).
rotationSteps: int: int
- Specifies the angle by which the gametest is rotate.
- 1 means 90° clockwise; 2 means 180°; 3 means 270° clockwise. Otherwise the gametest won't be rotated.
- Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ).
tag: string: string
- Specifies GameTest class to run.
- Must be an existing Gametest class ID.
width: int: int
- Specifies x-axis width of the polished andesite platform and of the structure. Defaults to 5.
- Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). And it should be less than or equal to 48.
height: int: int
- Specifies y-axis height of the polished andesite platform and of the structure. Defaults to 5.
- Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). And it should be less than or equal to 48.
depth: int: int
- Specifies z-axis width of the polished andesite platform and of the structure. Defaults to 5.
- Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). And it should be less than or equal to 48.
History
| Bedrock Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.16.210 | beta 1.16.210.60 | Added /gametest. | |||||
| 1.16.220 | 1.16.220.02 | Added stopOnFailure: Boolean and repeatCount: int into /gametest run .... | |||||
| 1.17.0 | beta 1.16.230.50 | Changed /gametest runall to /gametest runset. | |||||
| 1.18.30 | beta 1.18.20.27 | Removed radius: int argument in gametest clearall. | |||||
| 1.19.80 | Preview 1.19.80.22 | Added stopall and runsetuntilfail subcommands. | |||||