WorldTestContext provides direct access to the world, its ECS store, block operations, and tick-waiting primitives.
@WorldTest
Annotate a method with@WorldTest to receive a WorldTestContext. Tests are automatically tagged with "integration" and scheduled on the world thread.
Specifying a world
WorldTestContext Methods
| Category | Method | Description |
|---|---|---|
| World | getWorld() | Get the Hytale World object |
| Store | getStore() | Get the entity store |
getCommandBuffer() | Get a command buffer for deferred ops | |
flush() | Execute deferred command buffer operations | |
| Blocks | setBlock(x, y, z, typeId) | Set a block at coordinates |
getBlock(x, y, z) | Get the block type ID at coordinates | |
fillRegion(x1, y1, z1, x2, y2, z2, typeId) | Fill a region with blocks | |
| Entities | spawnEntity(typeId) | Spawn entity at origin |
spawnEntity(typeId, x, y, z) | Spawn entity at position | |
putComponent(ref, type, comp) | Attach component to entity | |
removeComponent(ref, type) | Remove component from entity | |
entityExists(ref) | Check if reference is still valid | |
despawn(ref) | Remove entity from world | |
| Position | getPosition(ref) | Get entity position as [x, y, z] |
setPosition(ref, x, y, z) | Set entity position | |
| Ticks | waitTicks(n) | Block until N ticks elapse |
waitTicksAsync(n) | Non-blocking tick wait | |
awaitCondition(supplier, maxTicks) | Poll each tick until non-null | |
| Queries | findEntities(componentType) | Find entities with component |
countEntities(componentType) | Count entities with component | |
getComponent(ref, type) | Get component (null if absent) | |
hasComponent(ref, type) | Check if entity has component |
WorldAssert Methods
| Method | Description |
|---|---|
assertBlockAt(world, x, y, z, typeId) | Assert block at position is expected type |
assertBlockNotAt(world, x, y, z, typeId) | Assert block is NOT the given type |
assertEntityInWorld(world, ref) | Assert entity exists in world |
assertWorldExists(worldName) | Assert a named world exists |
Examples
Spawn and verify entity position
Spawn and verify entity position
Set and verify block types
Set and verify block types
Fill a region and verify
Fill a region and verify
Despawn entity and verify removal
Despawn entity and verify removal
Isolation for World Tests
World tests that modify blocks or spawn entities should useIsolationStrategy.DEDICATED_WORLD to avoid polluting the live server:
Next Steps
- ECS Testing — lower-level entity/component operations
- Stats & Combat — health and damage verification
- Async & Tick Waiting — tick-based timing