<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sasgaming.net/index.php?action=history&amp;feed=atom&amp;title=Minecraft%3AGameTest</id>
	<title>Minecraft:GameTest - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sasgaming.net/index.php?action=history&amp;feed=atom&amp;title=Minecraft%3AGameTest"/>
	<link rel="alternate" type="text/html" href="https://wiki.sasgaming.net/index.php?title=Minecraft:GameTest&amp;action=history"/>
	<updated>2026-04-09T07:45:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.sasgaming.net/index.php?title=Minecraft:GameTest&amp;diff=50118&amp;oldid=prev</id>
		<title>imported&gt;Aloi4: /* Test environment */</title>
		<link rel="alternate" type="text/html" href="https://wiki.sasgaming.net/index.php?title=Minecraft:GameTest&amp;diff=50118&amp;oldid=prev"/>
		<updated>2026-03-29T17:29:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Test environment&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{redirect|Test}}&lt;br /&gt;
{{redirect|Gametest|the command|Commands/gametest}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;GameTest&amp;#039;&amp;#039;&amp;#039; is an automated {{wikipedia|end-to-end testing|end-to-end (E2E) testing}} framework for {{wikipedia|Software testing|testing}} aspects of &amp;#039;&amp;#039;[[Minecraft:Minecraft]]&amp;#039;&amp;#039;. Each test contains a structure, parameters for how the test gets executed, and optional code to further specify the test behavior.&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;Java Edition&amp;#039;&amp;#039; ==&lt;br /&gt;
=== Test instance ===&lt;br /&gt;
[[File:Test instance block UI.png|thumb|400px|UI of test instance block]]&lt;br /&gt;
&lt;br /&gt;
Test instance can be defined in a datapack by creating a [[Minecraft:JSON]] file in the {{cd|test_instance}} registry. Players can inspect information about them using a {{BlockLink|test instance block}}. A test instance has the following properties:&lt;br /&gt;
&lt;br /&gt;
* It belongs to a [[#Test environment|test environment]], which groups the test and further specifies the environment in which the test is run in. ({{nbt|compound}}{{nbt|string|environment}})&lt;br /&gt;
* It is associated with a {{nbt|string|structure}}, which should contain all the blocks and entities it needs to be run. The structure can be easily altered with the test instance block.&lt;br /&gt;
* It can either be a block-based test or a function test. More information is available below.&lt;br /&gt;
&lt;br /&gt;
There are more configuration available for test instances. For more information on the format, see [[Minecraft:test instance definition]].&lt;br /&gt;
&lt;br /&gt;
==== Block-based ====&lt;br /&gt;
In block-based tests, [[Minecraft:Test block]]s are used inside the test structure to control the test logic using [[Minecraft:redstone signal]].&lt;br /&gt;
&lt;br /&gt;
* {{BlockSprite|test-block-start}} &amp;#039;&amp;#039;&amp;#039;Start&amp;#039;&amp;#039;&amp;#039;: A [[Minecraft:redstone pulse]] is triggered when the test starts.&lt;br /&gt;
* {{BlockSprite|test-block-log}} &amp;#039;&amp;#039;&amp;#039;Log&amp;#039;&amp;#039;&amp;#039;: Logs a message to the log file when powered by redstone.&lt;br /&gt;
* {{BlockSprite|test-block-fail}} &amp;#039;&amp;#039;&amp;#039;Fail&amp;#039;&amp;#039;&amp;#039;: Fails the test when powered by redstone.&lt;br /&gt;
* {{BlockSprite|test-block-accept}} &amp;#039;&amp;#039;&amp;#039;Accept&amp;#039;&amp;#039;&amp;#039;: Completes the test when powered by redstone.&lt;br /&gt;
&lt;br /&gt;
If a race condition occurs, the first test block activated always wins.&lt;br /&gt;
&lt;br /&gt;
==== Function ====&lt;br /&gt;
Function tests rely on built-in test functions to determine a test&amp;#039;s success or failure. They are meant to be used by Mojang internally and by [[Minecraft:mod]] developers.&lt;br /&gt;
&lt;br /&gt;
The game provides the GameTest framework interfaces through the &amp;lt;code&amp;gt;net.minecraft.gametest.framework&amp;lt;/code&amp;gt; package ([[Minecraft:Obfuscation map|Mojang mapping]]). Mod loaders can use these to provide their own API for developers to use the GameTest framework – please refer to the respective documentation for [https://docs.fabricmc.net/develop/automatic-testing#game-tests Fabric] and [https://docs.neoforged.net/docs/misc/gametest NeoForge] for more information.&lt;br /&gt;
&lt;br /&gt;
A test function must be registered in the &amp;lt;code&amp;gt;test_function&amp;lt;/code&amp;gt; registry to be referenced in the test instance. The {{nbt|string|function}} field in the test instance definition should contain the [[Minecraft:resource location]] of the test function.&lt;br /&gt;
&lt;br /&gt;
=== Test environment ===&lt;br /&gt;
{{main|Test environment definition}}&lt;br /&gt;
&lt;br /&gt;
Test environment is a way to group up test instances and give them the right preconditions to run. It can be defined in a datapack by either creating a [[Minecraft:JSON]] file in the {{cd|test_instance}} registry or directly specified the environment inline with the {{nbt|compound|batch}} field. It can also use the test environment of the vanilla data package {{cd|minecraft:default}}, which is empty preconditions.&lt;br /&gt;
&lt;br /&gt;
=== Test command ===&lt;br /&gt;
{{main|Commands/test}}&lt;br /&gt;
The {{cmd|test}} command exists to execute and manage block-based tests. Some notable sub-commands include:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;/test (run|runmultiple) &amp;lt;tests&amp;gt; ...&amp;lt;/code&amp;gt; sub-commands can run specific test(s) for a number of times by their identifier.&lt;br /&gt;
* &amp;lt;code&amp;gt;/test (runclosest|runthat|runthese) ...&amp;lt;/code&amp;gt; sub-commands can run test(s) based on the player&amp;#039;s location.&lt;br /&gt;
* &amp;lt;code&amp;gt;/test (resetclosest|resetthat|resetthese)&amp;lt;/code&amp;gt; sub-commands reset the test structures for any tests.&lt;br /&gt;
* &amp;lt;code&amp;gt;/test locate &amp;lt;tests&amp;gt;&amp;lt;/code&amp;gt; locates test in loaded chunks.&lt;br /&gt;
&lt;br /&gt;
=== Server.jar entry point ===&lt;br /&gt;
The &amp;lt;code&amp;gt;net.minecraft.gametest.Main&amp;lt;/code&amp;gt; entry point is included in [[Minecraft:server.jar]] which starts a server, runs all available game tests and then exits. It can be invoked in the command line, such as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
java -DbundlerMainClass=&amp;quot;net.minecraft.gametest.Main&amp;quot; -jar server.jar [&amp;lt;options&amp;gt;]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Command-line options ====&lt;br /&gt;
* {{cd|--help}} - Shows usage information&lt;br /&gt;
* {{cd|--packs &amp;lt;path&amp;gt;}} - Set a folder of datapacks to include in the world&lt;br /&gt;
** Any zip file or folder with a {{cd|pack.mcmeta}} file is included&lt;br /&gt;
* {{cd|--report &amp;lt;path&amp;gt;}} - Exports results in a [https://junit.org/ junit]-like XML report at the given path&lt;br /&gt;
* {{cd|--tests &amp;lt;selection&amp;gt;}} - Specify which tests to run with a selection - a wildcard expression matching namespace test instance IDs&lt;br /&gt;
** If omitted, or used with an empty ID, runs all tests&lt;br /&gt;
* {{cd|--universe &amp;lt;path&amp;gt;}} - The path to where the test server world will be created&lt;br /&gt;
** Any existing folder will be replaced&lt;br /&gt;
** Default: {{cd|gametestserver}}&lt;br /&gt;
* {{cd|--verify &amp;lt;boolean&amp;gt;}} - Enables test verification&lt;br /&gt;
** Runs the tests specified with {{cd|test}} or {{cd|testNamespace}} 100 times for each 90 degree rotation step&lt;br /&gt;
** Default: {{cd|false}}&lt;br /&gt;
&lt;br /&gt;
==== Exit code ====&lt;br /&gt;
The game will yield the following {{wikipedia|exit code|exit codes}} depending on the scenario:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Scenario !! Exit code&lt;br /&gt;
|-&lt;br /&gt;
| All tests pass || 0&lt;br /&gt;
|-&lt;br /&gt;
| Any test fails || (number of failures)&lt;br /&gt;
|-&lt;br /&gt;
| Server shut down without starting tests || -1&lt;br /&gt;
|-&lt;br /&gt;
| Game crashed || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;Bedrock Edition&amp;#039;&amp;#039; ==&lt;br /&gt;
The GameTest framework can be accessed through the &amp;lt;code&amp;gt;@minecraft/server-gametest&amp;lt;/code&amp;gt; module from the [[Minecraft:Script API]]. The module must be added as a dependency in the [[Minecraft:manifest.json]]. It contains many {{w|programming interface}}s used for {{w|automated testing}} of any game objects&amp;#039; behaviors and interactions in a controlled testing environment.&amp;lt;ref&amp;gt;{{cite |url=https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/test?view=minecraft-bedrock-experimental |title=Test Class |website=Microsoft Learn |date=February 10, 2025}}&amp;lt;/ref&amp;gt; Developers can use these interfaces for:&lt;br /&gt;
* Asserting certain conditions for [[Minecraft:block]]s, [[Minecraft:entities]], and other game objects;&lt;br /&gt;
* Getting in-game information such as [[Minecraft:dimension]], [[Minecraft:position]], entities and blocks information;&lt;br /&gt;
* Modifying the testing environment by setting block permutation (block type and states data), sending [[Minecraft:redstone]] interactions, etc;&lt;br /&gt;
* Spawning entities controlled by the script with predictable mob behaviors;&lt;br /&gt;
* Creating simulated [[Minecraft:player]]s for testing behaviors and interactions with other game objects;&amp;lt;ref&amp;gt;{{cite |url=https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/simulatedplayer?view=minecraft-bedrock-experimental |title=SimulatedPlayer Class |website=Microsoft Learn |date=February 10, 2025}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* And other testing functionalities, [https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/test?view=minecraft-bedrock-experimental further reading].&lt;br /&gt;
&lt;br /&gt;
A testing environment can be created from a unit test (also called a &amp;#039;&amp;#039;GameTest&amp;#039;&amp;#039;), which contains a test function registered from the script, and a reference to a [[Minecraft:.mcstructure]] file exists in the behavior pack.&amp;lt;ref&amp;gt;{{cite |url=https://learn.microsoft.com/en-us/minecraft/creator/documents/gametestbuildyourfirstgametest?view=minecraft-bedrock-stable |title=Building your first GameTest |website=Microsoft Learn |date=June 20, 2024}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;registration-builder&amp;quot;/&amp;gt; Users can register a new unit test using &amp;lt;code&amp;gt;GameTest#register(&amp;#039;&amp;#039;testClassName&amp;#039;&amp;#039;, &amp;#039;&amp;#039;testName&amp;#039;&amp;#039;, &amp;#039;&amp;#039;testFunction&amp;#039;&amp;#039;)&amp;lt;/code&amp;gt; method with additional [[Minecraft:w:Builder pattern|builder]] parameters, such as &amp;lt;code&amp;gt;.maxTicks(&amp;#039;&amp;#039;ticks&amp;#039;&amp;#039;)&amp;lt;/code&amp;gt; that indicates the test may take amount of &amp;#039;&amp;#039;ticks&amp;#039;&amp;#039; to run, &amp;lt;code&amp;gt;.maxAttempts(&amp;#039;&amp;#039;attempts&amp;#039;&amp;#039;)&amp;lt;/code&amp;gt; which specifies how many attempt the test can run, and more.&amp;lt;ref name=&amp;quot;registration-builder&amp;quot;&amp;gt;{{cite |url=https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/registrationbuilder?view=minecraft-bedrock-experimental |title=RegistrationBuilder Class |website=Microsoft Learn |date=February 22, 2025}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the unit test is registered, it is loaded in the world, and can be run using the {{cmd|gametest}} command, referenced by &amp;lt;code&amp;gt;&amp;#039;&amp;#039;&amp;lt;testClassName&amp;gt;&amp;#039;&amp;#039;:&amp;#039;&amp;#039;&amp;lt;testName&amp;gt;&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;. When ran, the game spawns the test structure and calls the test function previously defined in the script. The unit test may succeed or fail depending on the test function, which usually contain instructions for testing behaviors and interactions in the testing environment.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
=== Demonstration ===&lt;br /&gt;
{{HistoryTable&lt;br /&gt;
|{{HistoryLine||November 9, 2020|link=https://www.youtube.com/watch?v=vXaWOJTCYNg|[[Minecraft:Henrik Kniberg]] demonstrated GameTest, a test framework used internally by Mojang, on the &amp;#039;&amp;#039;Agile with Jimmy&amp;#039;&amp;#039; YouTube channel.}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== &amp;#039;&amp;#039;Java Edition&amp;#039;&amp;#039; ===&lt;br /&gt;
{{HistoryTable&lt;br /&gt;
|{{HistoryLine|java}}&lt;br /&gt;
|{{HistoryLine||1.15|dev=19w34a|References to GameTest added in the game&amp;#039;s code. Most of the framework is stripped, since the rest of the game does not depend on it.}}&lt;br /&gt;
|{{HistoryLine||1.17|dev=21w13a|GameTest related code is now exposed for mod developers&amp;#039; use because unused parts of code are no longer removed.}}&lt;br /&gt;
|{{HistoryLine||1.21.5|dev=25w03a|Overhauled the GameTest framework.|Introduced for use with data packs.}}&lt;br /&gt;
|{{HistoryLine||1.21.11|dev=25w44a|In the {{cd|game_rules}} test environment the keys {{cd|bool_rule}} and {{cd|int_rule}} have been replaced with a single key rules.}}&lt;br /&gt;
|{{HistoryLine||26.1|dev=snap3|Replaced {{cd|time_of_day}} with {{cd|clock_time}}.|Added a new required field {{cd|clock}}: world clock ID, the clock within which to set time (from the existing time field).}}&lt;br /&gt;
|{{HistoryLine|||dev=snap11|Added {{cd|timeline_attributes}} definitions to set any number of timelines.}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== &amp;#039;&amp;#039;Bedrock Edition&amp;#039;&amp;#039; ===&lt;br /&gt;
{{HistoryTable&lt;br /&gt;
|{{HistoryLine|bedrock}}&lt;br /&gt;
|{{HistoryLine||1.16.210|dev=beta 1.16.210.60|Added GameTest framework.}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
{{Navbox Java Edition technical|general}}&lt;br /&gt;
{{Navbox Bedrock Edition}}&lt;br /&gt;
&lt;br /&gt;
[[Minecraft:de:Spieltest]]&lt;br /&gt;
[[Minecraft:ja:ゲームテスト]]&lt;br /&gt;
[[Minecraft:pt:GameTest]]&lt;br /&gt;
[[Minecraft:ru:Игровой тест]]&lt;br /&gt;
[[Minecraft:zh:游戏测试]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Aloi4</name></author>
	</entry>
</feed>