Running Tests
Run with Gradle
In the mod project, run the gameTests task. Use -PpolyTests to choose which tests to run.
- Windows (PowerShell)
- macOS · Linux (bash)
.\gradlew.bat gameTests "-PpolyTests=ruby_mod:*" # all of the mod's tests
.\gradlew.bat gameTests "-PpolyTests=ruby_mod:ruby_block_drops" # one test
./gradlew gameTests "-PpolyTests=ruby_mod:*" # all of the mod's tests
./gradlew gameTests "-PpolyTests=ruby_mod:ruby_block_drops" # one test
- It runs on a game test server, so no window opens.
- The result appears in the console as
All N required tests passed, or as the failed tests with their location and message. - If a test fails, the Gradle task fails too, so you can use it in CI as is.
Run inside the game
You can also run tests in a normal world with the /test command. This works because Poly Mod Loader's generation pack that uses the test structures is a known pack.
/test run ruby_mod:ruby_block_drops
/test runmultiple ruby_mod:*
Other check tasks
| Task | What it does |
|---|---|
worldCreateSaveTest | Loads the mod, creates and saves a world, and checks log lines (no window). Log check tests |
clientWorldReloadTest | Reopens the world that worldCreateSaveTest saved in the client (a window opens) |
serverBootSmokeTest | Boots a dedicated server up to the EULA check |
Check the parts that a game test server cannot check, such as client screens and rendering, yourself with runClient.
All tasks from the mod plugin
These are the tasks that the mod plugin dev.polymodloader.mod adds to a mod project. Run directories are relative to the mod project.
| Task | What it does | Run directory | Window |
|---|---|---|---|
validatePolyModJson | Validates src/main/resources/poly.mod.json with Poly Mod Loader's metadata checker. Included in check (build) | — | — |
prepareMinecraftClient | Downloads the Minecraft client, libraries, and assets, and verifies them by hash | Cache ~/.gradle/caches/poly-minecraft | — |
prepareMinecraftServer | Downloads and verifies the dedicated server, and unpacks the bundle | Cache ~/.gradle/caches/poly-minecraft | — |
runClient | Runs the client through Poly Mod Loader | run/client | Opens |
runServer | Runs a dedicated server through Poly Mod Loader. Requires EULA consent | run/server | None |
serverBootSmokeTest | Boots a dedicated server up to the EULA check | build/poly/server-boot-smoke | None |
worldCreateSaveTest | Creates a world on a game test server, runs the built-in test minecraft:always_pass, and checks the save | build/poly/world-create-save | None |
gameTests | Runs the mod's in-game tests. Choose them with -PpolyTests=<selector> | build/poly/game-tests | None |
clientWorldReloadTest | Reopens the world that worldCreateSaveTest saved in the client. Run worldCreateSaveTest first | build/poly/client-world-reload | Opens briefly |
startupBenchmark | Measures the time from start to stop of a game test server, alternating vanilla and Poly Mod Loader. The result is startup-benchmark.json | build/poly/startup-benchmark | None |
- The
run*andprepare*tasks are in thepoly minecraftgroup, and the check tasks are in theverificationgroup. - The directories under
build/poly/are deleted and recreated on every run. No world or settings from a previous run remain. - All runs share the transform cache
build/poly/transform-cache. - The mod project's jar is passed straight to Poly Mod Loader and is not copied to
mods/.runClientandrunServeralso load jars you put directly in the run directory'smods/(run/client/mods,run/server/mods).
Choose the Minecraft version to run
Runs and checks use one Minecraft version at a time. If you do not choose one, they use the default version of the Poly Mod Loader you use (now 26.2).
gradle.properties
polyMinecraft=26.2
To run with a different version just once, add -PpolyMinecraft to the command.
- Windows (PowerShell)
- macOS · Linux (bash)
.\gradlew.bat gameTests "-PpolyMinecraft=26.2" "-PpolyTests=ruby_mod:*"
./gradlew gameTests "-PpolyMinecraft=26.2" "-PpolyTests=ruby_mod:*"
- The version adapter and the Java toolchain used for the run follow the version you chose.
- If you choose a version Poly Mod Loader does not support, it shows the list of supported versions and fails.
- The
minecraftlist inpoly.mod.json, not this value, decides which versions the mod runs on. See poly.mod.json.
Run a dedicated server
- Windows (PowerShell)
- macOS · Linux (bash)
.\gradlew.bat runServer
./gradlew runServer
runServerruns a dedicated server inrun/server.- A dedicated server requires you to accept the Minecraft EULA. Poly Mod Loader does not accept it on your behalf. If
run/server/eula.txtdoes not containeula=true, the task fails with a guidance message before it starts the game. - Read the EULA yourself, and if you agree, write
eula=trueinrun/server/eula.txtyourself. serverBootSmokeTestdoes not need EULA consent. It starts in an empty directory every time, so the server stops at the EULA check, and the task checks only the log up to that point.