Skip to main content
HRTK provides two assertion classes for item-related testing: InventoryAssert for verifying inventory contents by section and slot, and LootAssert for verifying drop lists after entity kills or loot table rolls. Inventory and loot testing catches bugs that are easy to miss manually - items placed in the wrong slot, stacks that exceed their maximum, loot tables that drop nothing, or equipment that fails to appear in the armor section. Automated tests verify these mechanics consistently across every build.
Item IDs and drop list IDs used in examples depend on the game’s item registry. Replace with your mod’s actual item and drop list identifiers.

Inventory Section Constants

Inventories in Hytale are divided into sections. HRTK defines constants for the three standard sections: These constants keep your test code readable. Instead of writing magic numbers like 0 or 2, you write InventoryAssert.SECTION_HOTBAR.

Complete Example Suite

InventoryAssert Methods

LootAssert Methods

Inventory Testing Patterns

Inventory tests follow a consistent pattern:
  1. Spawn an NPC that has an inventory component
  2. Give items using ctx.giveItem(entity, itemId, count)
  3. Retrieve the inventory with ctx.getInventory(entity)
  4. Assert on slots, sections, or the whole inventory
For loot tests, the pattern is slightly different:
  1. Spawn an NPC, then kill it
  2. Collect drops using ctx.awaitCondition(() -> ctx.collectDrops(...), maxTicks)
  3. Assert on the drop list contents
When testing randomized loot, use @RepeatedTest to run the test multiple times and catch edge cases in drop distributions. Combine with assertDropCountBetween for range-based validation.

Next Steps