CraftingTestAdapter provides direct registry access, while CraftingAssert offers assertion methods that fail with clear messages when recipes are missing or counts fall short.
Crafting tests are smoke tests for your mod’s content pipeline. If a recipe ID is misspelled in a JSON file or a new recipe fails to register, these tests catch it immediately instead of waiting for a player to discover the missing recipe in-game.
Complete Example Suite
Adapter Methods
| Method | Returns | Description |
|---|---|---|
recipeExists(String recipeId) | boolean | Check if a recipe with the given ID exists in the registry |
listRecipeIds() | List<String> | List all registered recipe IDs |
craftingPluginAvailable() | boolean | Check if the crafting plugin class is present on the classpath |
Assertion Methods
| Method | Failure Message |
|---|---|
assertRecipeExists(String recipeId) | ”Expected recipe ‘[recipeId]’ to exist in registry but it was not found” |
assertRecipeCount(int minCount) | ”Expected at least [minCount] recipes but found [actual]“ |
Key Details
- Both the assert and adapter classes use reflection to locate the recipe registry - no compile-time dependency on
HytaleServer.jaris needed. - Use
listRecipeIds()fromCraftingTestAdapterto inspect the full registry contents when debugging a failing recipe assertion. craftingPluginAvailable()is useful as a precondition check before running recipe-specific tests.
Next Steps
- Inventory & Loot - test crafting outputs in inventories
- Items - verify crafted item properties
- Codecs - test recipe serialization