Test environment definition
Jump to navigation
Jump to search
This feature is exclusive to Java Edition.
A test environment is a way to group up GameTests and give them the right preconditions to run.
Definition
[edit | edit source]Test environments can be defined in data packs, as part of the directory structure below.
data pack name.zip or
data pack name
pack.mcmeta
data
namespace
test_environment
<name>.json
- More directories…
JSON Format
[edit | edit source]Test environments are defined using the following format:
- [NBT Compound / JSON Object] The root object.
- [String] type: Indicates how to set up the test. See below.
- Other additional fields depend on the value of [String] type, described below.
Environment types
[edit | edit source]all_of
[edit | edit source]Applies multiple environments
- [NBT Compound / JSON Object] The root object.
- [String] type:
all_of - [NBT List / JSON Array] definitions
- [String][NBT Compound / JSON Object]: One test environment (an [String] ID, or a new [NBT Compound / JSON Object] test environment definition) — Another test environment.
- [String] type:
function
[edit | edit source]Uses functions to set up and tear down the test.
game_rules
[edit | edit source]Applies game rules during the test, and resets them after tests have completed.
- [NBT Compound / JSON Object] The root object.
- [String] type:
game_rules - [NBT List / JSON Array] bool_rules: A list of boolean game rules to set and the value to set.
- [NBT Compound / JSON Object]: A map of boolean game rule.
- [String] rule: Name of the game rule.
- [Boolean] value: Value to set.
- [NBT Compound / JSON Object]: A map of boolean game rule.
- [NBT List / JSON Array] int_rules: A list of integer game rules to set and the value to set.
- [NBT Compound / JSON Object]: A map of integer game rule.
- [String] rule: Name of the game rule.
- [Int] value: Value to set.
- [NBT Compound / JSON Object]: A map of integer game rule.
- [String] type:
weather
[edit | edit source]Applies specific weather during the test, and resets it after tests have completed.
- [NBT Compound / JSON Object] The root object.
- [String] type:
weather - [String] weather: The weather to set. Must be one of
clear,rainandthunder.
- [String] type:
clock_time
[edit | edit source]Changes the time of a specified world clock to the specified value, and resets it after tests have completed.
- [NBT Compound / JSON Object] The root object.
- [String] type:
world_clock - [String] clock: One world clock (an [String] ID) of which to set the time.
- [Int] time: The time in ticks to set the clock to.
- [String] type:
History
[edit | edit source]| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.21.5 | 25w03a | Added test environment definition to data packs. | |||||
| 25w04a | Renamed raining environment type to weather | ||||||
| 26.1 | snap3 | Renamed time_of_day environment type to clock_time and added [String] clock field. | |||||