Test Features
Minecraft 1.21.5 (Snapshot 25w03a) introduced a major overhaul to the GameTest framework - an automated end-to-end testing system for datapack functionality. Kore provides a type-safe Kotlin DSL that generates JSON files for the test_instance and test_environment registries.
Test Environments
Test environments define the preconditions under which tests run. There are five types:
Weather
Sets a fixed weather condition:
Time of Day
Locks the time to a specific tick value:
Game Rules
Overrides game rules for controlled conditions:
Function
Runs datapack functions before (setup) and/or after (teardown) each test:
Combined (allOf)
Merges multiple environments into one:
Tip: You can also create environments outside a
testEnvironmentsblock usingtestEnvironmentsBuilder:This is useful when reusing environments across multiple test instances.
Test Instances
Test instances define the actual tests. Each one references a structure, an environment, and execution parameters.
Test Types
- Block-based (
blockBased()): Test logic is driven by redstone inside the structure using special test blocks (Start, Log, Fail, Accept). - Function-based (
functionBased()): Test logic is handled by a Java method reference (used by Mojang internally and mod developers). Requires afunctionfield with a fully qualified method reference (e.g.,"com.example.MyMod::myTest").
Creating Test Instances
Configuration Options
All available properties for a test instance:
| Property | Type | Description |
|---|---|---|
environment(env) |
TestEnvironmentArgument |
Required. The test environment to use. |
structure(struct) |
StructureArgument |
Required. The structure template for the test. |
blockBased() / functionBased() |
- | Sets the test type (default: block-based). |
function(fn) |
String |
Java method reference for function-based tests. |
maxTicks |
Int |
Maximum ticks before timeout (default: 100). |
setupTicks |
Int |
Ticks to wait before starting the test. |
maxAttempts |
Int |
Maximum retry attempts. |
requiredSuccesses |
Int |
Successes needed out of maxAttempts. |
required |
Boolean |
Whether the test must pass for the suite to succeed. |
manualOnly |
Boolean |
Whether the test is only run manually. |
skyAccess |
Boolean |
Whether the structure needs sky access. |
rotation(rot) |
TestRotation |
Rotation applied to the structure. |
Rotation helpers: noRotation(), clockwise90(), rotate180(), counterclockwise90().
Structures
Kore provides constants for all vanilla structures:
Test Commands
Selectors
Command Usage
In-Game Commands
Complete Example
Best Practices
- Combine environments with
allOffor complex scenarios. - Mark critical tests as
required = true. - Set appropriate timeouts with
maxTicks. - Use game rules to disable randomness (mob spawning, daylight cycle, tick speed).
- Reuse environments via
testEnvironmentsBuilderto avoid duplication.
See Also
- Functions - Kore's DSL for writing datapack functions.
- GameTest Framework - Official Minecraft documentation.
