TestContext
The base context available to all tests. Provides logging, event capture, and command execution.EcsTestContext
ExtendsTestContext. Provides direct ECS store access, entity creation, component operations, tick-waiting, and entity queries. Available when using @EcsTest.
WorldTestContext
ExtendsTestContext. Provides full world access including blocks, entity spawning, positioning, and all ECS operations. Available when using @WorldTest, @CombatTest, @SpawnTest, or @FlowTest.
executeOnWorld() exists because mod APIs often access the ECS Store internally, which requires the world thread. When your test runs on a different thread (like @FlowTest), wrap mod API calls in executeOnWorld() to avoid “Assert not in thread” errors.BenchmarkContext
ExtendsTestContext. Provides iteration info and manual timing control. Available when using @Benchmark.
Parameter Injection
HRTK’sTestExecutor resolves method parameters by type:
If a requested context type is not available (e.g., requesting
WorldTestContext in a non-world test), the parameter is injected as null. Design your tests to request only the context they need.Next Steps
- Annotations Reference - all 26 annotations
- Your First Test - context injection in practice
- How It Works - parameter injection internals