This guide walks you through creating a test class, writing test methods, using assertions, and running everything from the server console.Documentation Index
Fetch the complete documentation index at: https://docs.hrtk.frotty27.com/llms.txt
Use this file to discover all available pages before exploring further.
This guide covers HRTK’s built-in testing features. If you’re testing a mod that has its own API (spawn systems, query methods, custom events), see Testing Mod APIs for patterns specific to mod integration testing.
Prerequisites
Before you start, make sure:- Your mod project uses Gradle (or Maven) and can compile against
hrtk-api - The
hrtk-serverplugin JAR is in your server’splugins/directory - Your server is running with at least one world loaded
hrtk-api is a compile-only dependency. It provides annotations and assertion classes but is not needed at runtime - the server plugin handles everything.Step 1: Add the Dependency
In your mod’sbuild.gradle, add hrtk-api as a compile-only dependency:
build.gradle
Step 2: Create a Test Class
Create a new class in your mod’s source tree. Annotate it with@HytaleSuite to give it a name and group your tests.
MyFirstTests.java
Step 3: Use Assertions
HytaleAssert provides a full set of assertion methods. Here are the most common ones:
Step 4: Receive Context (Optional)
If your test needs access to the server environment, declare aTestContext parameter. HRTK injects it automatically.
TestContext, EcsTestContext, WorldTestContext, BenchmarkContext, and MockCommandSender. The runner inspects your method’s parameter types and provides the right implementation.
Step 5: Build and Run
Expected Output
After running, you should see formatted results in the console:Next Steps
Test Suites
Learn how to organize tests with @HytaleSuite, naming, and isolation strategies.
Lifecycle Hooks
Set up shared state with @BeforeAll, @AfterAll, @BeforeEach, and @AfterEach.
Filtering & Tags
Tag your tests and run subsets with —tag filters.
Assertion Reference
See the full annotation reference for all 24 HRTK annotations.