Skip to main content
Version: Minecraft 26.2

Running Tests

Run with Gradle​

In the mod project, run the gameTests task. Use -PpolyTests to choose which tests to run.

.\gradlew.bat gameTests "-PpolyTests=ruby_mod:*" # all of the mod's tests
.\gradlew.bat 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​

TaskWhat it does
worldCreateSaveTestLoads the mod, creates and saves a world, and checks log lines (no window). Log check tests
clientWorldReloadTestReopens the world that worldCreateSaveTest saved in the client (a window opens)
serverBootSmokeTestBoots 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.

TaskWhat it doesRun directoryWindow
validatePolyModJsonValidates src/main/resources/poly.mod.json with Poly Mod Loader's metadata checker. Included in check (build)——
prepareMinecraftClientDownloads the Minecraft client, libraries, and assets, and verifies them by hashCache ~/.gradle/caches/poly-minecraft—
prepareMinecraftServerDownloads and verifies the dedicated server, and unpacks the bundleCache ~/.gradle/caches/poly-minecraft—
runClientRuns the client through Poly Mod Loaderrun/clientOpens
runServerRuns a dedicated server through Poly Mod Loader. Requires EULA consentrun/serverNone
serverBootSmokeTestBoots a dedicated server up to the EULA checkbuild/poly/server-boot-smokeNone
worldCreateSaveTestCreates a world on a game test server, runs the built-in test minecraft:always_pass, and checks the savebuild/poly/world-create-saveNone
gameTestsRuns the mod's in-game tests. Choose them with -PpolyTests=<selector>build/poly/game-testsNone
clientWorldReloadTestReopens the world that worldCreateSaveTest saved in the client. Run worldCreateSaveTest firstbuild/poly/client-world-reloadOpens briefly
startupBenchmarkMeasures the time from start to stop of a game test server, alternating vanilla and Poly Mod Loader. The result is startup-benchmark.jsonbuild/poly/startup-benchmarkNone
  • The run* and prepare* tasks are in the poly minecraft group, and the check tasks are in the verification group.
  • 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/. runClient and runServer also load jars you put directly in the run directory's mods/ (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.

.\gradlew.bat 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 minecraft list in poly.mod.json, not this value, decides which versions the mod runs on. See poly.mod.json.

Run a dedicated server​

.\gradlew.bat runServer
  • runServer runs a dedicated server in run/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.txt does not contain eula=true, the task fails with a guidance message before it starts the game.
  • Read the EULA yourself, and if you agree, write eula=true in run/server/eula.txt yourself.
  • serverBootSmokeTest does 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.
Buy me a coffee