Skip to main content
IsolationStrategy.DEDICATED_WORLD creates a temporary void world for your suite, runs all tests inside it, and destroys it when the suite finishes. This provides the strongest isolation - nothing from your tests can affect the live server’s worlds.

When to Use

  • Tests that place or break blocks
  • Tests that spawn entities and need a clean environment
  • Integration tests and flow tests (spawn -> combat -> loot)
  • Any test that needs a predictable, empty world

How It Works

1

Before Suite

HRTK calls TestWorldManager.getOrCreateTestWorld(suiteId) to create a void world. The world has no terrain, no entities, and no blocks - a blank canvas.
2

Test Execution

Your @WorldTest and @FlowTest methods receive a WorldTestContext bound to the temporary world. You can spawn entities, place blocks, and modify state freely.
3

After Suite

HRTK calls TestWorldManager.cleanupTestWorld(suiteId) to destroy the world and all its contents. No trace remains.

Usage

Entity Spawning in Dedicated Worlds

Dedicated worlds are the safest place to spawn test entities. They will not collide with existing live-world entities, and cleanup is automatic.

Fallback Behavior

If HRTK cannot create a dedicated world (e.g., due to server configuration or resource limits), it logs a warning and falls back to running against live state:
If the dedicated world creation fails, your tests run with NONE isolation semantics. Any mutations will affect the live server. Monitor the console for fallback warnings.

Performance

Creating and destroying a world has significant overhead compared to NONE or SNAPSHOT. This cost is paid once per suite, not per test. For suites with many tests, the per-test amortized cost is small.
OperationTypical Cost
World creation50-200ms
World destruction10-50ms
Per-test executionSame as NONE
Group your world-mutating tests into a small number of suites to minimize the number of world creates/destroys. Each suite gets its own dedicated world.

Complete Example

Next Steps