Skip to main content
Hytale runs on a tick-based game loop. Many things - entity spawning, damage, loot drops, and component setup - only take effect after one or more ticks. If your test spawns an entity and immediately checks its state, the entity may not be fully set up yet. HRTK provides tools to wait for ticks so your tests can check state at the right time.
Entity names like Kweebec and item names used in examples below are from Hytale’s default content. Replace them with your mod’s actual entity roles and item identifiers.

Why Tick Waiting Matters

Consider this naive test:
The fix is to wait for the server to tick, giving the game loop time to finish setting up the entity:

waitTicks()

Pauses the test until the specified number of world ticks have passed. Available on both EcsTestContext and WorldTestContext.
waitTicks() pauses the test thread while the world keeps ticking normally. Your test resumes automatically once the requested number of ticks have passed.

Async variant

If you need non-blocking tick waiting (for concurrent operations), use waitTicksAsync():

awaitCondition()

Polls a condition every tick until it returns a non-null value, or times out after a maximum number of ticks. This is the preferred way to wait for something to happen without hardcoding tick counts.

With custom failure message

If the condition never returns a non-null value within maxTicks, awaitCondition() throws a RuntimeException with the failure message. The test is reported as ERRORED.

@AsyncTest

Marks a test as asynchronous. Methods with @AsyncTest are discovered and run automatically, just like @HytaleTest. The runner will wait up to timeoutTicks server ticks for the test to complete. If specified, timeoutTicks overrides the default timeout for that test.
@AsyncTest is useful for tests that depend on game timers, scheduled tasks, or multi-tick processes. The default timeoutTicks is 200 (~6.7 seconds at 30 TPS). This acts as a safety net to prevent tests from waiting forever. @FlowTest(timeoutTicks = N) works the same way.

Common Patterns

Next Steps